Skip to content

Commit

Permalink
fix: CJS and ESM exports (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph authored Dec 15, 2023
1 parent bea50b5 commit 71f85e1
Show file tree
Hide file tree
Showing 67 changed files with 764 additions and 313 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ module.exports = {
"coverage",
"dist",
"e2e",
"package-e2e",
"website",
"/*.js"
"/*.js",
"/*.mjs",
"/*.d.ts"
]
};
1 change: 1 addition & 0 deletions api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/api');
1 change: 1 addition & 0 deletions api.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/api.js';
5 changes: 2 additions & 3 deletions e2e/configs/default.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// eslint-disable-next-line node/no-extraneous-require,@typescript-eslint/no-var-requires,import/no-extraneous-dependencies
const _ = require('lodash');
const { Status } = require('jest-allure2-reporter');
const PRESET = process.env.ALLURE_PRESET ?? 'default';

/** @type {import('jest-allure2-reporter').ReporterOptions} */
Expand All @@ -9,12 +8,12 @@ const jestAllure2ReporterOptions = {
categories: [
{
name: 'Snapshot mismatches',
matchedStatuses: [Status.FAILED],
matchedStatuses: ['failed'],
messageRegex: /.*\btoMatch(?:[A-Za-z]+)?Snapshot\b.*/,
},
{
name: 'Timeouts',
matchedStatuses: [Status.BROKEN],
matchedStatuses: ['broken'],
messageRegex: /.*Exceeded timeout of.*/,
},
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { $Epic, $Feature, $Story, $Tag } from 'jest-allure2-reporter';

$Tag('client');
$Epic('Authentication');
$Feature('Restore account');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { $Epic, $Feature, $Story, $Tag } from 'jest-allure2-reporter';
import LoginHelper from '../../../../utils/LoginHelper';

/**
Expand Down
2 changes: 0 additions & 2 deletions e2e/src/programmatic/grouping/client/utils/validators.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { $Tag } from 'jest-allure2-reporter';

$Tag('client');
describe('Validators', () => {
describe('emailValidator', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { $Epic, $Feature, $Story, $Tag } from 'jest-allure2-reporter';

$Tag('server');
$Epic('Authentication');
$Feature('Restore account');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { $Epic, $Feature, $Story, $Tag } from 'jest-allure2-reporter';

$Tag('server');
$Epic('Authentication');
$Feature('Login');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { $Epic, $Feature, $Story, $Tag } from 'jest-allure2-reporter';

$Tag('server');
$Epic('Authentication');
$Feature('Restore account');
Expand Down
2 changes: 0 additions & 2 deletions e2e/src/utils/LoginHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {Attachment, FileAttachment, Step} from 'jest-allure2-reporter';

class LoginHelper {
#email?: string;
#password?: string;
Expand Down
3 changes: 2 additions & 1 deletion e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"module": "node16",
"ignoreDeprecations": "5.0",
"experimentalDecorators": true,
"noEmit": true
"noEmit": true,
"types": ["node", "jest", "jest-allure2-reporter/globals"]
}
}
3 changes: 1 addition & 2 deletions environment-jsdom.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// Fallback for Jest 27.x.x
module.exports = require('./dist/environment/jsdom');
module.exports = require('./dist/environment/jsdom').default;
5 changes: 5 additions & 0 deletions environment-jsdom.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import jsdom from './dist/environment/jsdom.js';

const { default: TestEnvironment } = jsdom;

export default TestEnvironment;
3 changes: 1 addition & 2 deletions environment-listener.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// Fallback for Jest 27.x.x
module.exports = require('./dist/environment/listener');
module.exports = require('./dist/environment/listener').default;
5 changes: 5 additions & 0 deletions environment-listener.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import environmentListener from './dist/environment/listener.js';

const { default: listener } = environmentListener;

export default listener;
3 changes: 1 addition & 2 deletions environment-node.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
// Fallback for Jest 27.x.x
module.exports = require('./dist/environment/node');
module.exports = require('./dist/environment/node').default;
5 changes: 5 additions & 0 deletions environment-node.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import node from './dist/environment/node.js';

const { default: TestEnvironment } = node;

export default TestEnvironment;
45 changes: 45 additions & 0 deletions globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as api from './dist/api';

declare global {
namespace NodeJS {
interface Global {
// Runtime API
allure: typeof api.allure;
// Pseudo-annotations
$Description: typeof api.$Description;
$DescriptionHtml: typeof api.$DescriptionHtml;
$Epic: typeof api.$Epic;
$Feature: typeof api.$Feature;
$Issue: typeof api.$Issue;
$Link: typeof api.$Link;
$Owner: typeof api.$Owner;
$Severity: typeof api.$Severity;
$Story: typeof api.$Story;
$Tag: typeof api.$Tag;
$TmsLink: typeof api.$TmsLink;
// Decorators
Attachment: typeof api.Attachment;
FileAttachment: typeof api.FileAttachment;
Step: typeof api.Step;
}
}

// Runtime API
var allure: typeof api.allure;
// Pseudo-annotations
var $Description: typeof api.$Description;
var $DescriptionHtml: typeof api.$DescriptionHtml;
var $Epic: typeof api.$Epic;
var $Feature: typeof api.$Feature;
var $Issue: typeof api.$Issue;
var $Link: typeof api.$Link;
var $Owner: typeof api.$Owner;
var $Severity: typeof api.$Severity;
var $Story: typeof api.$Story;
var $Tag: typeof api.$Tag;
var $TmsLink: typeof api.$TmsLink;
// Decorators
var Attachment: typeof api.Attachment;
var FileAttachment: typeof api.FileAttachment;
var Step: typeof api.Step;
}
1 change: 1 addition & 0 deletions globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
1 change: 1 addition & 0 deletions globals.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
Loading

0 comments on commit 71f85e1

Please sign in to comment.