diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 1e8dc7251..4a039bd3f 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -22,6 +22,7 @@ module.exports = { warnOnUnsupportedTypeScriptVersion: false, }, plugins: ["n", "no-null", "prefer-arrow", "import", "jsdoc", "@typescript-eslint"], + ignorePatterns: ["**/dist/**/*"], rules: { "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/adjacent-overload-signatures": "error", diff --git a/.pnp.cjs b/.pnp.cjs index 8441e43b3..5fe4eeff6 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -176,6 +176,15 @@ const RAW_RUNTIME_STATE = ["picocolors", "npm:1.0.0"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.24.7", {\ + "packageLocation": "./.yarn/cache/@babel-code-frame-npm-7.24.7-315a600a58-4812e94885.zip/node_modules/@babel/code-frame/",\ + "packageDependencies": [\ + ["@babel/code-frame", "npm:7.24.7"],\ + ["@babel/highlight", "npm:7.24.7"],\ + ["picocolors", "npm:1.0.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/compat-data", [\ @@ -691,6 +700,13 @@ const RAW_RUNTIME_STATE = ["@babel/helper-string-parser", "npm:7.24.6"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.24.7", {\ + "packageLocation": "./.yarn/cache/@babel-helper-string-parser-npm-7.24.7-560b175e3f-603d8d962b.zip/node_modules/@babel/helper-string-parser/",\ + "packageDependencies": [\ + ["@babel/helper-string-parser", "npm:7.24.7"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/helper-validator-identifier", [\ @@ -707,6 +723,13 @@ const RAW_RUNTIME_STATE = ["@babel/helper-validator-identifier", "npm:7.24.6"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.24.7", {\ + "packageLocation": "./.yarn/cache/@babel-helper-validator-identifier-npm-7.24.7-748889c8d2-86875063f5.zip/node_modules/@babel/helper-validator-identifier/",\ + "packageDependencies": [\ + ["@babel/helper-validator-identifier", "npm:7.24.7"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/helper-validator-option", [\ @@ -779,6 +802,17 @@ const RAW_RUNTIME_STATE = ["picocolors", "npm:1.0.0"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.24.7", {\ + "packageLocation": "./.yarn/cache/@babel-highlight-npm-7.24.7-d792bd8d9f-69b73f38cd.zip/node_modules/@babel/highlight/",\ + "packageDependencies": [\ + ["@babel/highlight", "npm:7.24.7"],\ + ["@babel/helper-validator-identifier", "npm:7.24.7"],\ + ["chalk", "npm:2.4.2"],\ + ["js-tokens", "npm:4.0.0"],\ + ["picocolors", "npm:1.0.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/parser", [\ @@ -797,6 +831,14 @@ const RAW_RUNTIME_STATE = ["@babel/types", "npm:7.23.9"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.24.7", {\ + "packageLocation": "./.yarn/cache/@babel-parser-npm-7.24.7-79d233f3d1-ef9ebce60e.zip/node_modules/@babel/parser/",\ + "packageDependencies": [\ + ["@babel/parser", "npm:7.24.7"],\ + ["@babel/types", "npm:7.23.9"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/plugin-bugfix-firefox-class-in-computed-class-key", [\ @@ -3140,6 +3182,16 @@ const RAW_RUNTIME_STATE = ["@babel/types", "npm:7.24.6"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.24.7", {\ + "packageLocation": "./.yarn/cache/@babel-template-npm-7.24.7-d08a527e2b-5975d404ef.zip/node_modules/@babel/template/",\ + "packageDependencies": [\ + ["@babel/template", "npm:7.24.7"],\ + ["@babel/code-frame", "npm:7.24.7"],\ + ["@babel/parser", "npm:7.24.7"],\ + ["@babel/types", "npm:7.24.7"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/traverse", [\ @@ -3224,6 +3276,16 @@ const RAW_RUNTIME_STATE = ["to-fast-properties", "npm:2.0.0"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.24.7", {\ + "packageLocation": "./.yarn/cache/@babel-types-npm-7.24.7-43a9e43e29-ad3c8c0d6f.zip/node_modules/@babel/types/",\ + "packageDependencies": [\ + ["@babel/types", "npm:7.24.7"],\ + ["@babel/helper-string-parser", "npm:7.24.7"],\ + ["@babel/helper-validator-identifier", "npm:7.24.7"],\ + ["to-fast-properties", "npm:2.0.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@bcoe/v8-coverage", [\ @@ -6412,6 +6474,7 @@ const RAW_RUNTIME_STATE = ["@typescript-eslint/parser", "virtual:a59b12f7fe7bf3b80fc61d73eaaa33af60483f6ce31789d384fbe8ef169791f667d2559ec5f2fbae1a273a658ce021f1f5f1ea0718c56f81b30ad4e95a5668dd#npm:7.10.0"],\ ["allure-js-commons", "workspace:packages/allure-js-commons"],\ ["babel-plugin-add-module-exports", "npm:1.0.4"],\ + ["babel-plugin-transform-import-meta", "virtual:ab27e3168e0bdfb2dc5b30f86375269d7862a0be07fda8f1a257183a90c281219d82f6498de90bd23a4b5fcb916cfc7e850768c6711fc7742befb82622788606#npm:2.2.1"],\ ["chai", "npm:4.4.1"],\ ["chai-like", "virtual:606d5fd11adc18cba076ddb26a9b3adaf466a45eef985b60ea990c3ead5fe6bcc20990b0ed8d0763c4a8c861cdc2277964415bf12191df7c6923d8e78816abf5#npm:1.1.1"],\ ["chai-things", "npm:0.2.0"],\ @@ -6422,6 +6485,7 @@ const RAW_RUNTIME_STATE = ["eslint-plugin-n", "virtual:3b04c8c38dde7165df844f9cd74e94cc47d78164564600cf56ba5f8c6011d25ef0d3afc13d610f3da970f6807c830914053ff96a43c86ba17f3ec650dfd687d3#npm:17.7.0"],\ ["eslint-plugin-no-null", "virtual:a59b12f7fe7bf3b80fc61d73eaaa33af60483f6ce31789d384fbe8ef169791f667d2559ec5f2fbae1a273a658ce021f1f5f1ea0718c56f81b30ad4e95a5668dd#npm:1.0.2"],\ ["eslint-plugin-prefer-arrow", "virtual:a59b12f7fe7bf3b80fc61d73eaaa33af60483f6ce31789d384fbe8ef169791f667d2559ec5f2fbae1a273a658ce021f1f5f1ea0718c56f81b30ad4e95a5668dd#npm:1.2.3"],\ + ["glob", "npm:10.4.1"],\ ["mocha", "npm:10.3.0"],\ ["npm-run-all2", "npm:6.1.2"],\ ["rimraf", "npm:5.0.5"],\ @@ -7076,6 +7140,30 @@ const RAW_RUNTIME_STATE = "linkType": "HARD"\ }]\ ]],\ + ["babel-plugin-transform-import-meta", [\ + ["npm:2.2.1", {\ + "packageLocation": "./.yarn/cache/babel-plugin-transform-import-meta-npm-2.2.1-0927fef047-d6db38b379.zip/node_modules/babel-plugin-transform-import-meta/",\ + "packageDependencies": [\ + ["babel-plugin-transform-import-meta", "npm:2.2.1"]\ + ],\ + "linkType": "SOFT"\ + }],\ + ["virtual:ab27e3168e0bdfb2dc5b30f86375269d7862a0be07fda8f1a257183a90c281219d82f6498de90bd23a4b5fcb916cfc7e850768c6711fc7742befb82622788606#npm:2.2.1", {\ + "packageLocation": "./.yarn/__virtual__/babel-plugin-transform-import-meta-virtual-4f7e20a233/0/cache/babel-plugin-transform-import-meta-npm-2.2.1-0927fef047-d6db38b379.zip/node_modules/babel-plugin-transform-import-meta/",\ + "packageDependencies": [\ + ["babel-plugin-transform-import-meta", "virtual:ab27e3168e0bdfb2dc5b30f86375269d7862a0be07fda8f1a257183a90c281219d82f6498de90bd23a4b5fcb916cfc7e850768c6711fc7742befb82622788606#npm:2.2.1"],\ + ["@babel/core", "npm:7.24.6"],\ + ["@babel/template", "npm:7.24.7"],\ + ["@types/babel__core", "npm:7.20.5"],\ + ["tslib", "npm:2.6.3"]\ + ],\ + "packagePeers": [\ + "@babel/core",\ + "@types/babel__core"\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["babel-preset-current-node-syntax", [\ ["npm:1.0.1", {\ "packageLocation": "./.yarn/cache/babel-preset-current-node-syntax-npm-1.0.1-849ec71e32-94561959cb.zip/node_modules/babel-preset-current-node-syntax/",\ @@ -10897,6 +10985,18 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:10.4.1", {\ + "packageLocation": "./.yarn/cache/glob-npm-10.4.1-a0d030e0a9-d7bb49d2b4.zip/node_modules/glob/",\ + "packageDependencies": [\ + ["glob", "npm:10.4.1"],\ + ["foreground-child", "npm:3.1.1"],\ + ["jackspeak", "npm:3.4.0"],\ + ["minimatch", "npm:9.0.4"],\ + ["minipass", "npm:7.1.2"],\ + ["path-scurry", "npm:1.11.1"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:6.0.1", {\ "packageLocation": "./.yarn/cache/glob-npm-6.0.1-8e9c8956b1-a0670bc51f.zip/node_modules/glob/",\ "packageDependencies": [\ @@ -12101,6 +12201,15 @@ const RAW_RUNTIME_STATE = ["@pkgjs/parseargs", "npm:0.11.0"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:3.4.0", {\ + "packageLocation": "./.yarn/cache/jackspeak-npm-3.4.0-fdc2c6fcce-5032c43c0c.zip/node_modules/jackspeak/",\ + "packageDependencies": [\ + ["jackspeak", "npm:3.4.0"],\ + ["@isaacs/cliui", "npm:8.0.2"],\ + ["@pkgjs/parseargs", "npm:0.11.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["jasmine", [\ @@ -13419,6 +13528,13 @@ const RAW_RUNTIME_STATE = ],\ "linkType": "HARD"\ }],\ + ["npm:10.2.2", {\ + "packageLocation": "./.yarn/cache/lru-cache-npm-10.2.2-c54b721fc3-ff1a496d30.zip/node_modules/lru-cache/",\ + "packageDependencies": [\ + ["lru-cache", "npm:10.2.2"]\ + ],\ + "linkType": "HARD"\ + }],\ ["npm:4.1.5", {\ "packageLocation": "./.yarn/cache/lru-cache-npm-4.1.5-ede304cc43-9ec7d73f11.zip/node_modules/lru-cache/",\ "packageDependencies": [\ @@ -13749,6 +13865,13 @@ const RAW_RUNTIME_STATE = ["minipass", "npm:7.0.4"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.1.2", {\ + "packageLocation": "./.yarn/cache/minipass-npm-7.1.2-3a5327d36d-c25f0ee819.zip/node_modules/minipass/",\ + "packageDependencies": [\ + ["minipass", "npm:7.1.2"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["minipass-collect", [\ @@ -14941,6 +15064,15 @@ const RAW_RUNTIME_STATE = ["minipass", "npm:7.0.4"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:1.11.1", {\ + "packageLocation": "./.yarn/cache/path-scurry-npm-1.11.1-aaf8c339af-5e8845c159.zip/node_modules/path-scurry/",\ + "packageDependencies": [\ + ["path-scurry", "npm:1.11.1"],\ + ["lru-cache", "npm:10.2.2"],\ + ["minipass", "npm:7.0.4"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["path-to-regexp", [\ @@ -17598,6 +17730,13 @@ const RAW_RUNTIME_STATE = ["tslib", "npm:2.6.2"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:2.6.3", {\ + "packageLocation": "./.yarn/cache/tslib-npm-2.6.3-0fd136b3be-52109bb681.zip/node_modules/tslib/",\ + "packageDependencies": [\ + ["tslib", "npm:2.6.3"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["tunnel-agent", [\ diff --git a/.yarn/cache/@babel-code-frame-npm-7.24.7-315a600a58-4812e94885.zip b/.yarn/cache/@babel-code-frame-npm-7.24.7-315a600a58-4812e94885.zip new file mode 100644 index 000000000..5eb87a30e Binary files /dev/null and b/.yarn/cache/@babel-code-frame-npm-7.24.7-315a600a58-4812e94885.zip differ diff --git a/.yarn/cache/@babel-helper-string-parser-npm-7.24.7-560b175e3f-603d8d962b.zip b/.yarn/cache/@babel-helper-string-parser-npm-7.24.7-560b175e3f-603d8d962b.zip new file mode 100644 index 000000000..6422f0418 Binary files /dev/null and b/.yarn/cache/@babel-helper-string-parser-npm-7.24.7-560b175e3f-603d8d962b.zip differ diff --git a/.yarn/cache/@babel-helper-validator-identifier-npm-7.24.7-748889c8d2-86875063f5.zip b/.yarn/cache/@babel-helper-validator-identifier-npm-7.24.7-748889c8d2-86875063f5.zip new file mode 100644 index 000000000..021881058 Binary files /dev/null and b/.yarn/cache/@babel-helper-validator-identifier-npm-7.24.7-748889c8d2-86875063f5.zip differ diff --git a/.yarn/cache/@babel-highlight-npm-7.24.7-d792bd8d9f-69b73f38cd.zip b/.yarn/cache/@babel-highlight-npm-7.24.7-d792bd8d9f-69b73f38cd.zip new file mode 100644 index 000000000..9df46bf31 Binary files /dev/null and b/.yarn/cache/@babel-highlight-npm-7.24.7-d792bd8d9f-69b73f38cd.zip differ diff --git a/.yarn/cache/@babel-parser-npm-7.24.7-79d233f3d1-ef9ebce60e.zip b/.yarn/cache/@babel-parser-npm-7.24.7-79d233f3d1-ef9ebce60e.zip new file mode 100644 index 000000000..86d5369d1 Binary files /dev/null and b/.yarn/cache/@babel-parser-npm-7.24.7-79d233f3d1-ef9ebce60e.zip differ diff --git a/.yarn/cache/@babel-template-npm-7.24.7-d08a527e2b-5975d404ef.zip b/.yarn/cache/@babel-template-npm-7.24.7-d08a527e2b-5975d404ef.zip new file mode 100644 index 000000000..7f0562c32 Binary files /dev/null and b/.yarn/cache/@babel-template-npm-7.24.7-d08a527e2b-5975d404ef.zip differ diff --git a/.yarn/cache/@babel-types-npm-7.24.7-43a9e43e29-ad3c8c0d6f.zip b/.yarn/cache/@babel-types-npm-7.24.7-43a9e43e29-ad3c8c0d6f.zip new file mode 100644 index 000000000..be847ba0b Binary files /dev/null and b/.yarn/cache/@babel-types-npm-7.24.7-43a9e43e29-ad3c8c0d6f.zip differ diff --git a/.yarn/cache/babel-plugin-transform-import-meta-npm-2.2.1-0927fef047-d6db38b379.zip b/.yarn/cache/babel-plugin-transform-import-meta-npm-2.2.1-0927fef047-d6db38b379.zip new file mode 100644 index 000000000..06bcf1e7b Binary files /dev/null and b/.yarn/cache/babel-plugin-transform-import-meta-npm-2.2.1-0927fef047-d6db38b379.zip differ diff --git a/.yarn/cache/glob-npm-10.4.1-a0d030e0a9-d7bb49d2b4.zip b/.yarn/cache/glob-npm-10.4.1-a0d030e0a9-d7bb49d2b4.zip new file mode 100644 index 000000000..8d44135f2 Binary files /dev/null and b/.yarn/cache/glob-npm-10.4.1-a0d030e0a9-d7bb49d2b4.zip differ diff --git a/.yarn/cache/jackspeak-npm-3.4.0-fdc2c6fcce-5032c43c0c.zip b/.yarn/cache/jackspeak-npm-3.4.0-fdc2c6fcce-5032c43c0c.zip new file mode 100644 index 000000000..04721e4ed Binary files /dev/null and b/.yarn/cache/jackspeak-npm-3.4.0-fdc2c6fcce-5032c43c0c.zip differ diff --git a/.yarn/cache/lru-cache-npm-10.2.2-c54b721fc3-ff1a496d30.zip b/.yarn/cache/lru-cache-npm-10.2.2-c54b721fc3-ff1a496d30.zip new file mode 100644 index 000000000..7e71190c3 Binary files /dev/null and b/.yarn/cache/lru-cache-npm-10.2.2-c54b721fc3-ff1a496d30.zip differ diff --git a/.yarn/cache/minipass-npm-7.1.2-3a5327d36d-c25f0ee819.zip b/.yarn/cache/minipass-npm-7.1.2-3a5327d36d-c25f0ee819.zip new file mode 100644 index 000000000..4c88fb60c Binary files /dev/null and b/.yarn/cache/minipass-npm-7.1.2-3a5327d36d-c25f0ee819.zip differ diff --git a/.yarn/cache/path-scurry-npm-1.11.1-aaf8c339af-5e8845c159.zip b/.yarn/cache/path-scurry-npm-1.11.1-aaf8c339af-5e8845c159.zip new file mode 100644 index 000000000..40cc3d66f Binary files /dev/null and b/.yarn/cache/path-scurry-npm-1.11.1-aaf8c339af-5e8845c159.zip differ diff --git a/.yarn/cache/tslib-npm-2.6.3-0fd136b3be-52109bb681.zip b/.yarn/cache/tslib-npm-2.6.3-0fd136b3be-52109bb681.zip new file mode 100644 index 000000000..a62a327b9 Binary files /dev/null and b/.yarn/cache/tslib-npm-2.6.3-0fd136b3be-52109bb681.zip differ diff --git a/packages/allure-mocha/.eslintrc.cjs b/packages/allure-mocha/.eslintrc.cjs index f984d96a7..11cde1789 100644 --- a/packages/allure-mocha/.eslintrc.cjs +++ b/packages/allure-mocha/.eslintrc.cjs @@ -3,4 +3,20 @@ module.exports = { parserOptions: { project: ["./tsconfig.json", "./tsconfig.test.json"], }, + overrides: [ + { + files: ["**/*.cjs", "**/*.js"], + rules: { + "@typescript-eslint/no-require-imports": "off", + "@typescript-eslint/no-var-requires": "off", + }, + }, + { + files: ["./test/fixtures/samples/**/*.js", "./test/fixtures/runner.js"], + rules: { + "no-undef": "off", + "@typescript-eslint/no-unsafe-argument": "off", + }, + }, + ], }; diff --git a/packages/allure-mocha/babel.cjs.json b/packages/allure-mocha/babel.cjs.json index 8d5e10dfa..d3de84c86 100644 --- a/packages/allure-mocha/babel.cjs.json +++ b/packages/allure-mocha/babel.cjs.json @@ -8,7 +8,7 @@ ], ["@babel/preset-env", { "modules": "commonjs" }] ], - "plugins": ["babel-plugin-add-module-exports"], + "plugins": ["babel-plugin-add-module-exports", "babel-plugin-transform-import-meta"], "targets": { "esmodules": false, "node": 18 diff --git a/packages/allure-mocha/package.json b/packages/allure-mocha/package.json index 8115c3b15..504ed1748 100644 --- a/packages/allure-mocha/package.json +++ b/packages/allure-mocha/package.json @@ -48,7 +48,9 @@ "lint:fix": "eslint ./src ./test --ext .ts --fix", "test": "run-s 'test:*'", "test:serial": "vitest run", - "test:parallel": "ALLURE_MOCHA_TEST_PARALLEL=true vitest run" + "test:parallel": "ALLURE_MOCHA_TEST_PARALLEL=true vitest run", + "test:runner": "ALLURE_MOCHA_TEST_RUNNER=cjs ALLURE_MOCHA_TEST_SPEC_FORMAT=cjs vitest run", + "test:runner-parallel": "ALLURE_MOCHA_TEST_RUNNER=esm ALLURE_MOCHA_TEST_SPEC_FORMAT=esm ALLURE_MOCHA_TEST_PARALLEL=true vitest run" }, "dependencies": { "allure-js-commons": "workspace:*" @@ -67,6 +69,7 @@ "@typescript-eslint/eslint-plugin": "^7.0.0", "@typescript-eslint/parser": "^7.0.0", "babel-plugin-add-module-exports": "^1.0.4", + "babel-plugin-transform-import-meta": "^2.2.1", "chai": "^4.3.8", "chai-like": "^1.1.1", "chai-things": "^0.2.0", @@ -77,6 +80,7 @@ "eslint-plugin-n": "^17.0.0", "eslint-plugin-no-null": "^1.0.2", "eslint-plugin-prefer-arrow": "^1.2.3", + "glob": "^10.4.1", "mocha": "^10.2.0", "npm-run-all2": "^6.1.2", "rimraf": "^5.0.1", diff --git a/packages/allure-mocha/src/MochaAllureReporter.ts b/packages/allure-mocha/src/AllureMochaReporter.ts similarity index 98% rename from packages/allure-mocha/src/MochaAllureReporter.ts rename to packages/allure-mocha/src/AllureMochaReporter.ts index 69cdfb1bd..45a21de87 100644 --- a/packages/allure-mocha/src/MochaAllureReporter.ts +++ b/packages/allure-mocha/src/AllureMochaReporter.ts @@ -28,7 +28,7 @@ const { EVENT_HOOK_END, } = Mocha.Runner.constants; -export class MochaAllureReporter extends Mocha.reporters.Base { +export class AllureMochaReporter extends Mocha.reporters.Base { private readonly runtime: ReporterRuntime; constructor(runner: Mocha.Runner, opts: Mocha.MochaOptions) { diff --git a/packages/allure-mocha/src/index.ts b/packages/allure-mocha/src/index.ts index 4cab2e0e9..bc4518fac 100644 --- a/packages/allure-mocha/src/index.ts +++ b/packages/allure-mocha/src/index.ts @@ -1,3 +1,3 @@ -import { MochaAllureReporter } from "./MochaAllureReporter.js"; +import { AllureMochaReporter } from "./AllureMochaReporter.js"; -export default MochaAllureReporter; +export default AllureMochaReporter; diff --git a/packages/allure-mocha/src/legacy.ts b/packages/allure-mocha/src/legacy.ts index e75da98a2..c58c29c1b 100644 --- a/packages/allure-mocha/src/legacy.ts +++ b/packages/allure-mocha/src/legacy.ts @@ -17,36 +17,105 @@ interface AttachmentOptions { fileExtension?: string; } +/** + * @deprecated please use api exported by "allure-js-commons" instead. + */ class LegacyAllureApi { + /** + * @deprecated please use import { epic } from "allure-js-commons" instead. + */ epic = (epic: string) => Promise.resolve(commons.epic(epic)); + /** + * @deprecated please use import { feature } from "allure-js-commons" instead. + */ feature = (feature: string) => Promise.resolve(commons.feature(feature)); + /** + * @deprecated please use import { story } from "allure-js-commons" instead. + */ story = (story: string) => Promise.resolve(commons.story(story)); + /** + * @deprecated please use import { suite } from "allure-js-commons" instead. + */ suite = (name: string) => Promise.resolve(commons.suite(name)); + /** + * @deprecated please use import { parentSuite } from "allure-js-commons" instead. + */ parentSuite = (name: string) => Promise.resolve(commons.parentSuite(name)); + /** + * @deprecated please use import { subSuite } from "allure-js-commons" instead. + */ subSuite = (name: string) => Promise.resolve(commons.subSuite(name)); + /** + * @deprecated please use import { label } from "allure-js-commons" instead. + */ label = (name: string, value: string) => Promise.resolve(commons.label(name, value)); + /** + * @deprecated please use import { parameter } from "allure-js-commons" instead. + */ parameter = (name: string, value: any, options?: ParameterOptions) => Promise.resolve(commons.parameter(name, serialize(value) as string, options)); + /** + * @deprecated please use import { link } from "allure-js-commons" instead. + */ link = (url: string, name?: string, type?: string) => Promise.resolve(commons.link(url, name, type)); + /** + * @deprecated please use import { issue } from "allure-js-commons" instead. + */ issue = (name: string, url: string) => Promise.resolve(commons.issue(url, name)); + /** + * @deprecated please use import { tms } from "allure-js-commons" instead. + */ tms = (name: string, url: string) => Promise.resolve(commons.tms(url, name)); + /** + * @deprecated please use import { description } from "allure-js-commons" instead. + */ description = (markdown: string) => Promise.resolve(commons.description(markdown)); + /** + * @deprecated please use import { descriptionHtml } from "allure-js-commons" instead. + */ descriptionHtml = (html: string) => Promise.resolve(commons.descriptionHtml(html)); + /** + * @deprecated please use import { owner } from "allure-js-commons" instead. + */ owner = (owner: string) => Promise.resolve(commons.owner(owner)); + /** + * @deprecated please use import { severity } from "allure-js-commons" instead. + */ severity = (severity: string) => Promise.resolve(commons.severity(severity)); + /** + * @deprecated please use import { layer } from "allure-js-commons" instead. + */ layer = (layer: string) => Promise.resolve(commons.layer(layer)); + /** + * @deprecated please use import { allureId } from "allure-js-commons" instead. + */ id = (allureId: string) => Promise.resolve(commons.allureId(allureId)); + /** + * @deprecated please use import { tag } from "allure-js-commons" instead. + */ tag = (tag: string) => Promise.resolve(commons.tag(tag)); + /** + * @deprecated please use the `environmentInfo` config option instead. + */ writeEnvironmentInfo = (info: Record) => { getLegacyApiRuntime()?.writer.writeEnvironmentInfo(info); }; + /** + * @deprecated please use the `categories` config option instead. + */ writeCategoriesDefinitions = (categories: Category[]) => { getLegacyApiRuntime()?.writer.writeCategoriesDefinitions(categories); }; + /** + * @deprecated please use import { attachment } from "allure-js-commons" instead. + */ attachment = (name: string, content: Buffer | string, options: ContentType | string | AttachmentOptions) => Promise.resolve( commons.attachment(name, content, typeof options === "string" ? { contentType: options } : options), ); + /** + * @deprecated please use import { attachment } from "allure-js-commons" instead. + */ testAttachment = (name: string, content: Buffer | string, options: ContentType | string | AttachmentOptions) => { const runtime = getLegacyApiRuntime(); const currentTest = runtime?.getCurrentTest(); @@ -62,13 +131,19 @@ class LegacyAllureApi { ); } }; - // eslint-disable-next-line @typescript-eslint/no-unused-vars + /** + * @deprecated please use import { step } from "allure-js-commons" instead. + */ logStep = (name: string, status?: Status) => { this.step(name, () => { getLegacyApiRuntime()?.updateStep((s) => (s.status = status)); }); }; + // It's sync-first. That's why we can't simply reuse commons.step. + /** + * @deprecated please use import { step } from "allure-js-commons" instead. + */ step = (name: string, body: (step: StepInterface) => T): T => { const runtime = getLegacyApiRuntime(); runtime?.applyRuntimeMessages([ diff --git a/packages/allure-mocha/src/runtime.ts b/packages/allure-mocha/src/runtime.ts deleted file mode 100644 index 43a4a7aa1..000000000 --- a/packages/allure-mocha/src/runtime.ts +++ /dev/null @@ -1 +0,0 @@ -export { MochaAllureReporter } from "./MochaAllureReporter.js"; diff --git a/packages/allure-mocha/src/setupAllureMochaParallel.ts b/packages/allure-mocha/src/setupAllureMochaParallel.ts index b38462434..f7c651f1e 100644 --- a/packages/allure-mocha/src/setupAllureMochaParallel.ts +++ b/packages/allure-mocha/src/setupAllureMochaParallel.ts @@ -1,12 +1,13 @@ import type * as Mocha from "mocha"; // @ts-ignore import { default as ParallelBuffered } from "mocha/lib/nodejs/reporters/parallel-buffered.js"; -import { MochaAllureReporter } from "./MochaAllureReporter.js"; +import { AllureMochaReporter } from "./AllureMochaReporter.js"; const originalCreateListeners: (runner: Mocha.Runner) => Mocha.reporters.Base = ParallelBuffered.prototype.createListeners; ParallelBuffered.prototype.createListeners = function (runner: Mocha.Runner) { - new MochaAllureReporter(runner, this.options as Mocha.MochaOptions); - return originalCreateListeners.call(this, runner); + const result = originalCreateListeners.call(this, runner); + new AllureMochaReporter(runner, this.options as Mocha.MochaOptions); + return result; }; diff --git a/packages/allure-mocha/src/utils.ts b/packages/allure-mocha/src/utils.ts index 968278a1a..6b480e04f 100644 --- a/packages/allure-mocha/src/utils.ts +++ b/packages/allure-mocha/src/utils.ts @@ -1,14 +1,18 @@ import type * as Mocha from "mocha"; import { hostname } from "node:os"; -import { extname, join } from "node:path"; +import { dirname, extname, join } from "node:path"; import { env, pid } from "node:process"; +import { fileURLToPath } from "node:url"; import { isMainThread, threadId } from "node:worker_threads"; import type { Label } from "allure-js-commons"; import { LabelName } from "allure-js-commons"; +const filename = fileURLToPath(import.meta.url); + export const getSuitesOfMochaTest = (test: Mocha.Test) => test.titlePath().slice(0, -1); -export const resolveParallelModeSetupFile = () => join(__dirname, `setupAllureMochaParallel${extname(__filename)}`); +export const resolveParallelModeSetupFile = () => + join(dirname(filename), `setupAllureMochaParallel${extname(filename)}`); export const resolveMochaWorkerId = () => env.MOCHA_WORKER_ID ?? (isMainThread ? pid : threadId).toString(); diff --git a/packages/allure-mocha/test/fixtures/AllureMochaParallelWriter.cjs b/packages/allure-mocha/test/fixtures/AllureMochaParallelWriter.cjs index 2c2fc2c5b..ccc1dd607 100644 --- a/packages/allure-mocha/test/fixtures/AllureMochaParallelWriter.cjs +++ b/packages/allure-mocha/test/fixtures/AllureMochaParallelWriter.cjs @@ -1,10 +1,8 @@ -/* eslint @typescript-eslint/no-require-imports: 0 */ -/* eslint @typescript-eslint/no-var-requires: 0 */ /* eslint no-underscore-dangle: 0 */ const ParallelBuffered = require("mocha/lib/nodejs/reporters/parallel-buffered.js"); const { MessageWriter } = require("allure-js-commons/sdk/reporter"); -class MochaParallelWriter extends MessageWriter { +class AllureMochaParallelWriter extends MessageWriter { constructor() { super(); this.events = []; @@ -16,7 +14,7 @@ class MochaParallelWriter extends MessageWriter { } } -const writer = new MochaParallelWriter(); +const writer = new AllureMochaParallelWriter(); const originalDone = ParallelBuffered.prototype.done; ParallelBuffered.prototype.done = function (failures, callback) { diff --git a/packages/allure-mocha/test/fixtures/reporter.cjs b/packages/allure-mocha/test/fixtures/reporter.cjs index c01ed417d..3dd8d6aa3 100644 --- a/packages/allure-mocha/test/fixtures/reporter.cjs +++ b/packages/allure-mocha/test/fixtures/reporter.cjs @@ -1,10 +1,8 @@ -/* eslint @typescript-eslint/no-require-imports: 0 */ -/* eslint @typescript-eslint/no-var-requires: 0 */ /* eslint @typescript-eslint/no-unsafe-argument: 0 */ -const MochaAllureReporter = require("allure-mocha"); +const AllureMochaReporter = require("allure-mocha"); const path = require("path"); -class ProcessMessageAllureReporter extends MochaAllureReporter { +class ProcessMessageAllureReporter extends AllureMochaReporter { constructor(runner, opts) { if (opts.reporterOptions?.emitFiles !== "true") { opts.reporterOptions = { diff --git a/packages/allure-mocha/test/fixtures/runner.js b/packages/allure-mocha/test/fixtures/runner.js new file mode 100644 index 000000000..f2d3cae88 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/runner.js @@ -0,0 +1,52 @@ +// cjs: const { Glob } = require("glob"); +// cjs: const path = require("path"); +// cjs: const Mocha = require("mocha"); +// cjs: const AllureReporter = require("allure-mocha"); +// esm: import { Glob } from "glob"; +// esm: import path from "path"; +// esm: import { fileURLToPath } from "url"; +// esm: import Mocha from "mocha"; +// esm: import AllureReporter from "allure-mocha"; + +// cjs: const dirname = __dirname; +// esm: const dirname = path.dirname(fileURLToPath(import.meta.url)); + +let emitFiles = false; +let parallel = false; +const requires = []; + +const sepIndex = process.argv.indexOf("--"); +const args = sepIndex === -1 ? [] : process.argv.splice(sepIndex); +for (const arg of args) { + switch (arg) { + case "--emit-files": + emitFiles = true; + break; + case "--parallel": + parallel = true; + // cjs: require("./setupParallel.cjs"); + // esm: await import("./setupParallel.cjs"); + requires.push(path.join(dirname, "setupParallel.cjs")); + break; + } +} + +const mocha = new Mocha({ + reporter: AllureReporter, + reporterOptions: { + writer: emitFiles ? undefined : "MessageWriter", + }, + parallel, + require: requires, + color: false, +}); + +const run = async () => { + for await (const file of new Glob("./**/*.spec.*", {})) { + mocha.addFile(path.resolve(file)); + } + await mocha.loadFilesAsync(); + mocha.run((failures) => process.exit(failures)); +}; + +run(); diff --git a/packages/allure-mocha/test/fixtures/samples/description.spec.js b/packages/allure-mocha/test/fixtures/samples/description.spec.js new file mode 100644 index 000000000..a4ed9f797 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/description.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { description } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { description } from "allure-js-commons"; + +it("a test with a description", async () => { + await description("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/description.spec.mjs b/packages/allure-mocha/test/fixtures/samples/description.spec.mjs deleted file mode 100644 index c7a9330a7..000000000 --- a/packages/allure-mocha/test/fixtures/samples/description.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { description } from "allure-js-commons"; - -it("a test with a description", async () => { - await description("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/descriptionHtml.spec.js b/packages/allure-mocha/test/fixtures/samples/descriptionHtml.spec.js new file mode 100644 index 000000000..7bd864ba7 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/descriptionHtml.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { descriptionHtml } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { descriptionHtml } from "allure-js-commons"; + +it("a test with a description in HTML", async () => { + await descriptionHtml("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/descriptionHtml.spec.mjs b/packages/allure-mocha/test/fixtures/samples/descriptionHtml.spec.mjs deleted file mode 100644 index a4c83f3d4..000000000 --- a/packages/allure-mocha/test/fixtures/samples/descriptionHtml.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { descriptionHtml } from "allure-js-commons"; - -it("a test with a description in HTML", async () => { - await descriptionHtml("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/fixtures/after.spec.mjs b/packages/allure-mocha/test/fixtures/samples/fixtures/after.spec.js similarity index 56% rename from packages/allure-mocha/test/fixtures/samples/fixtures/after.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/fixtures/after.spec.js index 83c6d396c..7e920eec0 100644 --- a/packages/allure-mocha/test/fixtures/samples/fixtures/after.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/fixtures/after.spec.js @@ -1,4 +1,5 @@ -import { after, describe, it } from "mocha"; +// cjs: const { after, describe, it } = require("mocha"); +// esm: import { after, describe, it } from "mocha"; describe("a suite with after", async () => { after("an after all hook", async () => {}); diff --git a/packages/allure-mocha/test/fixtures/samples/fixtures/afterEach.spec.mjs b/packages/allure-mocha/test/fixtures/samples/fixtures/afterEach.spec.js similarity index 57% rename from packages/allure-mocha/test/fixtures/samples/fixtures/afterEach.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/fixtures/afterEach.spec.js index 438192654..3f8cfaa35 100644 --- a/packages/allure-mocha/test/fixtures/samples/fixtures/afterEach.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/fixtures/afterEach.spec.js @@ -1,4 +1,5 @@ -import { afterEach, describe, it } from "mocha"; +// cjs: const { afterEach, describe, it } = require("mocha"); +// esm: import { afterEach, describe, it } from "mocha"; describe("a suite with afterEach", async () => { afterEach("an after each hook", async () => {}); diff --git a/packages/allure-mocha/test/fixtures/samples/fixtures/before.spec.mjs b/packages/allure-mocha/test/fixtures/samples/fixtures/before.spec.js similarity index 57% rename from packages/allure-mocha/test/fixtures/samples/fixtures/before.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/fixtures/before.spec.js index b4f77db2e..076122ebb 100644 --- a/packages/allure-mocha/test/fixtures/samples/fixtures/before.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/fixtures/before.spec.js @@ -1,4 +1,5 @@ -import { before, describe, it } from "mocha"; +// cjs: const { before, describe, it } = require("mocha"); +// esm: import { before, describe, it } from "mocha"; describe("a suite with before", async () => { before("a before all hook", async () => {}); diff --git a/packages/allure-mocha/test/fixtures/samples/fixtures/beforeEach.spec.mjs b/packages/allure-mocha/test/fixtures/samples/fixtures/beforeEach.spec.js similarity index 57% rename from packages/allure-mocha/test/fixtures/samples/fixtures/beforeEach.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/fixtures/beforeEach.spec.js index 1fa8b4dc9..a79c25567 100644 --- a/packages/allure-mocha/test/fixtures/samples/fixtures/beforeEach.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/fixtures/beforeEach.spec.js @@ -1,4 +1,5 @@ -import { beforeEach, describe, it } from "mocha"; +// cjs: const { beforeEach, describe, it } = require("mocha"); +// esm: import { beforeEach, describe, it } from "mocha"; describe("a suite with beforeEach", async () => { beforeEach("a before each hook", async () => {}); diff --git a/packages/allure-mocha/test/fixtures/samples/fixtures/renamed.spec.js b/packages/allure-mocha/test/fixtures/samples/fixtures/renamed.spec.js new file mode 100644 index 000000000..46a07c4fd --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/fixtures/renamed.spec.js @@ -0,0 +1,12 @@ +// cjs: const { beforeEach, describe, it } = require("mocha"); +// cjs: const { displayName } = require("allure-js-commons"); +// esm: import { beforeEach, describe, it } from "mocha"; +// esm: import { displayName } from "allure-js-commons"; + +describe("a suite with before", async () => { + beforeEach("an initial name", async () => { + await displayName("a new name"); + }); + + it("a test affected by a renamed fixture", async () => {}); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/fixtures/renamed.spec.mjs b/packages/allure-mocha/test/fixtures/samples/fixtures/renamed.spec.mjs deleted file mode 100644 index 64f1c5d09..000000000 --- a/packages/allure-mocha/test/fixtures/samples/fixtures/renamed.spec.mjs +++ /dev/null @@ -1,10 +0,0 @@ -import { beforeEach, describe, it } from "mocha"; -import { displayName } from "allure-js-commons"; - -describe("a suite with before", async () => { - beforeEach("an initial name", async () => { - await displayName("a new name"); - }); - - it("a test affected by a renamed fixture", async () => {}); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/bdd/epic.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/bdd/epic.spec.js new file mode 100644 index 000000000..541893736 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/bdd/epic.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { epic } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { epic } from "allure-js-commons"; + +it("a test with an epic", async () => { + await epic("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/bdd/epic.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/bdd/epic.spec.mjs deleted file mode 100644 index f7f4db5fd..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/bdd/epic.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { epic } from "allure-js-commons"; - -it("a test with an epic", async () => { - await epic("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/bdd/feature.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/bdd/feature.spec.js new file mode 100644 index 000000000..36608b5d8 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/bdd/feature.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { feature } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { feature } from "allure-js-commons"; + +it("a test with a feature", async () => { + await feature("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/bdd/feature.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/bdd/feature.spec.mjs deleted file mode 100644 index d10fd24da..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/bdd/feature.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { feature } from "allure-js-commons"; - -it("a test with a feature", async () => { - await feature("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/bdd/story.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/bdd/story.spec.js new file mode 100644 index 000000000..249867f56 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/bdd/story.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { story } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { story } from "allure-js-commons"; + +it("a test with a story", async () => { + await story("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/bdd/story.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/bdd/story.spec.mjs deleted file mode 100644 index fed3238e6..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/bdd/story.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { story } from "allure-js-commons"; - -it("a test with a story", async () => { - await story("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/custom.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/custom.spec.js new file mode 100644 index 000000000..11183081b --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/custom.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { label } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { label } from "allure-js-commons"; + +it("a test with a custom label", async () => { + await label("foo", "bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/custom.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/custom.spec.mjs deleted file mode 100644 index 8b353937f..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/custom.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { label } from "allure-js-commons"; - -it("a test with a custom label", async () => { - await label("foo", "bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/layer.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/layer.spec.js new file mode 100644 index 000000000..d72ebbdd3 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/layer.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { layer } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { layer } from "allure-js-commons"; + +it("a test with a layer", async () => { + await layer("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/layer.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/layer.spec.mjs deleted file mode 100644 index b0d159d65..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/layer.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { layer } from "allure-js-commons"; - -it("a test with a layer", async () => { - await layer("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/multiple.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/multiple.spec.js new file mode 100644 index 000000000..39515266d --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/multiple.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { labels } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { labels } from "allure-js-commons"; + +it("a test with two custom labels", async () => { + await labels({ name: "foo", value: "bar" }, { name: "baz", value: "qux" }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/multiple.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/multiple.spec.mjs deleted file mode 100644 index 40533b57b..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/multiple.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { labels } from "allure-js-commons"; - -it("a test with two custom labels", async () => { - await labels({ name: "foo", value: "bar" }, { name: "baz", value: "qux" }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/owner.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/owner.spec.js new file mode 100644 index 000000000..b8c1f8a82 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/owner.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { owner } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { owner } from "allure-js-commons"; + +it("a test with an owner", async () => { + await owner("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/owner.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/owner.spec.mjs deleted file mode 100644 index a918132ba..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/owner.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { owner } from "allure-js-commons"; - -it("a test with an owner", async () => { - await owner("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/blocker.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/severities/blocker.spec.js new file mode 100644 index 000000000..635bd9d52 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/severities/blocker.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { Severity, severity } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { Severity, severity } from "allure-js-commons"; + +it("a blocker", async () => { + await severity(Severity.BLOCKER); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/blocker.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/severities/blocker.spec.mjs deleted file mode 100644 index ed1406174..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/severities/blocker.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { Severity, severity } from "allure-js-commons"; - -it("a blocker", async () => { - await severity(Severity.BLOCKER); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/critical.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/severities/critical.spec.js new file mode 100644 index 000000000..86f740b8a --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/severities/critical.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { Severity, severity } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { Severity, severity } from "allure-js-commons"; + +it("a critical test", async () => { + await severity(Severity.CRITICAL); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/critical.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/severities/critical.spec.mjs deleted file mode 100644 index 8f51f0c75..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/severities/critical.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { Severity, severity } from "allure-js-commons"; - -it("a critical test", async () => { - await severity(Severity.CRITICAL); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/minor.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/severities/minor.spec.js new file mode 100644 index 000000000..20536a579 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/severities/minor.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { Severity, severity } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { Severity, severity } from "allure-js-commons"; + +it("a minor test", async () => { + await severity(Severity.MINOR); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/minor.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/severities/minor.spec.mjs deleted file mode 100644 index cf8164c6d..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/severities/minor.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { Severity, severity } from "allure-js-commons"; - -it("a minor test", async () => { - await severity(Severity.MINOR); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/normal.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/severities/normal.spec.js new file mode 100644 index 000000000..14c35fa98 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/severities/normal.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { Severity, severity } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { Severity, severity } from "allure-js-commons"; + +it("a normal test", async () => { + await severity(Severity.NORMAL); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/normal.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/severities/normal.spec.mjs deleted file mode 100644 index 350376202..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/severities/normal.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { Severity, severity } from "allure-js-commons"; - -it("a normal test", async () => { - await severity(Severity.NORMAL); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/trivial.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/severities/trivial.spec.js new file mode 100644 index 000000000..094a9b9cc --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/severities/trivial.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { Severity, severity } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { Severity, severity } from "allure-js-commons"; + +it("a trivial test", async () => { + await severity(Severity.TRIVIAL); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/severities/trivial.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/severities/trivial.spec.mjs deleted file mode 100644 index 933732aa4..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/severities/trivial.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { Severity, severity } from "allure-js-commons"; - -it("a trivial test", async () => { - await severity(Severity.TRIVIAL); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteFileScope.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteFileScope.spec.js new file mode 100644 index 000000000..92e216c70 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteFileScope.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { parentSuite } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { parentSuite } from "allure-js-commons"; + +it("a test with a parent suite", async () => { + await parentSuite("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteFileScope.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteFileScope.spec.mjs deleted file mode 100644 index 39ed55669..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteFileScope.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { parentSuite } from "allure-js-commons"; - -it("a test with a parent suite", async () => { - await parentSuite("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteNestedScope.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteNestedScope.spec.js similarity index 52% rename from packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteNestedScope.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteNestedScope.spec.js index f975282f4..6c1d853ca 100644 --- a/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteNestedScope.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/labels/suites/parentSuiteNestedScope.spec.js @@ -1,5 +1,7 @@ -import { it } from "mocha"; -import { parentSuite } from "allure-js-commons"; +// cjs: const { it } = require("mocha"); +// cjs: const { parentSuite } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { parentSuite } from "allure-js-commons"; describe("foo", async () => { describe("bar", async () => { diff --git a/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteFileScope.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteFileScope.spec.js new file mode 100644 index 000000000..8f743471d --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteFileScope.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { subSuite } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { subSuite } from "allure-js-commons"; + +it("a test with a sub-suite", async () => { + await subSuite("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteFileScope.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteFileScope.spec.mjs deleted file mode 100644 index ff3af264b..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteFileScope.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { subSuite } from "allure-js-commons"; - -it("a test with a sub-suite", async () => { - await subSuite("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteNestedScope.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteNestedScope.spec.js similarity index 52% rename from packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteNestedScope.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteNestedScope.spec.js index e8c8c31d0..333e8dcb3 100644 --- a/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteNestedScope.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/labels/suites/subSuiteNestedScope.spec.js @@ -1,5 +1,7 @@ -import { it } from "mocha"; -import { subSuite } from "allure-js-commons"; +// cjs: const { it } = require("mocha"); +// cjs: const { subSuite } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { subSuite } from "allure-js-commons"; describe("foo", async () => { describe("bar", async () => { diff --git a/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteFileScope.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteFileScope.spec.js new file mode 100644 index 000000000..9301d117c --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteFileScope.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { suite } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { suite } from "allure-js-commons"; + +it("a test with a suite", async () => { + await suite("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteFileScope.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteFileScope.spec.mjs deleted file mode 100644 index 65b94d1b2..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteFileScope.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { suite } from "allure-js-commons"; - -it("a test with a suite", async () => { - await suite("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteNestedScope.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteNestedScope.spec.js similarity index 52% rename from packages/allure-mocha/test/fixtures/samples/labels/suites/suiteNestedScope.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/labels/suites/suiteNestedScope.spec.js index 1456bc1ba..5f03f97fd 100644 --- a/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteNestedScope.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/labels/suites/suiteNestedScope.spec.js @@ -1,5 +1,7 @@ -import { it } from "mocha"; -import { suite } from "allure-js-commons"; +// cjs: const { it } = require("mocha"); +// cjs: const { suite } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { suite } from "allure-js-commons"; describe("foo", async () => { describe("bar", async () => { diff --git a/packages/allure-mocha/test/fixtures/samples/labels/tags.spec.js b/packages/allure-mocha/test/fixtures/samples/labels/tags.spec.js new file mode 100644 index 000000000..24f5e4dc8 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/labels/tags.spec.js @@ -0,0 +1,9 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { tag } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { tag } from "allure-js-commons"; + +it("a test with tags", async () => { + await tag("foo"); + await tag("bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/labels/tags.spec.mjs b/packages/allure-mocha/test/fixtures/samples/labels/tags.spec.mjs deleted file mode 100644 index 851b1a483..000000000 --- a/packages/allure-mocha/test/fixtures/samples/labels/tags.spec.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { it } from "mocha"; -import { tag } from "allure-js-commons"; - -it("a test with tags", async () => { - await tag("foo"); - await tag("bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/categories.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/categories.spec.js similarity index 100% rename from packages/allure-mocha/test/fixtures/samples/legacy/categories.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/legacy/categories.spec.js diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/description.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/description.spec.js new file mode 100644 index 000000000..505ab5363 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/description.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a description", () => { + allure.description("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/description.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/description.spec.mjs deleted file mode 100644 index 5ffec3555..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/description.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a description", () => { - allure.description("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/descriptionHtml.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/descriptionHtml.spec.js new file mode 100644 index 000000000..8e20ac9c2 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/descriptionHtml.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a description in HTML", () => { + allure.descriptionHtml("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/descriptionHtml.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/descriptionHtml.spec.mjs deleted file mode 100644 index 71156c7b7..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/descriptionHtml.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a description in HTML", () => { - allure.descriptionHtml("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/environmentInfo.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/environmentInfo.spec.js similarity index 100% rename from packages/allure-mocha/test/fixtures/samples/legacy/environmentInfo.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/legacy/environmentInfo.spec.js diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/fixtures/renamed.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/fixtures/renamed.spec.js new file mode 100644 index 000000000..3ff29c986 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/fixtures/renamed.spec.js @@ -0,0 +1,12 @@ +// cjs: const { beforeEach, describe, it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { beforeEach, describe, it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +describe("a suite with before", () => { + beforeEach("an initial name", () => { + allure.displayName("a new name"); + }); + + it("a test affected by a renamed fixture", () => {}); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/fixtures/renamed.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/fixtures/renamed.spec.mjs deleted file mode 100644 index 77568de38..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/fixtures/renamed.spec.mjs +++ /dev/null @@ -1,10 +0,0 @@ -import { beforeEach, describe, it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -describe("a suite with before", () => { - beforeEach("an initial name", () => { - allure.displayName("a new name"); - }); - - it("a test affected by a renamed fixture", () => {}); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/epic.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/epic.spec.js new file mode 100644 index 000000000..5a801b1d8 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/epic.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with an epic", () => { + allure.epic("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/epic.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/epic.spec.mjs deleted file mode 100644 index e11d0d308..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/epic.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with an epic", () => { - allure.epic("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/feature.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/feature.spec.js new file mode 100644 index 000000000..ab899db9e --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/feature.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a feature", () => { + allure.feature("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/feature.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/feature.spec.mjs deleted file mode 100644 index af2d850c8..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/feature.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a feature", () => { - allure.feature("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/story.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/story.spec.js new file mode 100644 index 000000000..ef893ce2d --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/story.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a story", () => { + allure.story("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/story.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/story.spec.mjs deleted file mode 100644 index d3c543bdf..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/bdd/story.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a story", () => { - allure.story("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/custom.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/custom.spec.js new file mode 100644 index 000000000..7a7d37afb --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/custom.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a custom label", () => { + allure.label("foo", "bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/custom.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/custom.spec.mjs deleted file mode 100644 index 7dd244ac5..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/custom.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a custom label", () => { - allure.label("foo", "bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/layer.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/layer.spec.js new file mode 100644 index 000000000..7e3b47f4f --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/layer.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a layer", () => { + allure.layer("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/layer.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/layer.spec.mjs deleted file mode 100644 index 3426d6ad4..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/layer.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a layer", () => { - allure.layer("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/owner.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/owner.spec.js new file mode 100644 index 000000000..9e571041a --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/owner.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with an owner", () => { + allure.owner("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/owner.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/owner.spec.mjs deleted file mode 100644 index 3edf3d273..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/owner.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with an owner", () => { - allure.owner("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/blocker.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/blocker.spec.js new file mode 100644 index 000000000..af3a3657f --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/blocker.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a blocker", () => { + allure.severity("blocker"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/blocker.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/blocker.spec.mjs deleted file mode 100644 index 4b988722a..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/blocker.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a blocker", () => { - allure.severity("blocker"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/critical.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/critical.spec.js new file mode 100644 index 000000000..b66c49bdb --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/critical.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a critical test", () => { + allure.severity("critical"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/critical.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/critical.spec.mjs deleted file mode 100644 index 2b178a941..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/critical.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a critical test", () => { - allure.severity("critical"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/minor.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/minor.spec.js new file mode 100644 index 000000000..d89654230 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/minor.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a minor test", () => { + allure.severity("minor"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/minor.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/minor.spec.mjs deleted file mode 100644 index 139bc6054..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/minor.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a minor test", () => { - allure.severity("minor"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/normal.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/normal.spec.js new file mode 100644 index 000000000..c119feb1f --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/normal.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a normal test", () => { + allure.severity("normal"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/normal.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/normal.spec.mjs deleted file mode 100644 index 1c731b500..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/normal.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a normal test", () => { - allure.severity("normal"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/trivial.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/trivial.spec.js new file mode 100644 index 000000000..69f6c2de4 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/trivial.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a trivial test", () => { + allure.severity("trivial"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/trivial.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/trivial.spec.mjs deleted file mode 100644 index a5a057c3f..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/severities/trivial.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a trivial test", () => { - allure.severity("trivial"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/parentSuite.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/parentSuite.spec.js new file mode 100644 index 000000000..277c8b20d --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/parentSuite.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a parent suite", () => { + allure.parentSuite("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/parentSuite.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/parentSuite.spec.mjs deleted file mode 100644 index 1122fa819..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/parentSuite.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a parent suite", () => { - allure.parentSuite("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/subSuite.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/subSuite.spec.js new file mode 100644 index 000000000..9e1259485 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/subSuite.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a sub-suite", () => { + allure.subSuite("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/subSuite.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/subSuite.spec.mjs deleted file mode 100644 index 0c288e8f6..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/subSuite.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a sub-suite", () => { - allure.subSuite("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/suite.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/suite.spec.js new file mode 100644 index 000000000..5b38ea440 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/suite.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a suite", () => { + allure.suite("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/suite.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/suite.spec.mjs deleted file mode 100644 index 1c1221a40..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/suites/suite.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a suite", () => { - allure.suite("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/tags.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/labels/tags.spec.js new file mode 100644 index 000000000..b059189eb --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/labels/tags.spec.js @@ -0,0 +1,9 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with tags", () => { + allure.tag("foo"); + allure.tag("bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/labels/tags.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/labels/tags.spec.mjs deleted file mode 100644 index e3b9d056d..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/labels/tags.spec.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with tags", () => { - allure.tag("foo"); - allure.tag("bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/issue.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/links/issue.spec.js new file mode 100644 index 000000000..dc988ea79 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/links/issue.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with an issue link", () => { + allure.issue("baz", "https://foo.bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/issue.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/links/issue.spec.mjs deleted file mode 100644 index 79aed6f95..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/links/issue.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with an issue link", () => { - allure.issue("baz", "https://foo.bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/namedLink.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/links/namedLink.spec.js new file mode 100644 index 000000000..6efaf8447 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/links/namedLink.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a named link", () => { + allure.link("https://foo.bar", "baz"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/namedLink.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/links/namedLink.spec.mjs deleted file mode 100644 index 44a8a1410..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/links/namedLink.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a named link", () => { - allure.link("https://foo.bar", "baz"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/tms.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/links/tms.spec.js new file mode 100644 index 000000000..3e567696d --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/links/tms.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a tms link", () => { + allure.tms("baz", "https://foo.bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/tms.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/links/tms.spec.mjs deleted file mode 100644 index 0d79d0566..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/links/tms.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a tms link", () => { - allure.tms("baz", "https://foo.bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/urlOnlyLink.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/links/urlOnlyLink.spec.js new file mode 100644 index 000000000..68e6e5e87 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/links/urlOnlyLink.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a url only link", () => { + allure.link("https://foo.bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/urlOnlyLink.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/links/urlOnlyLink.spec.mjs deleted file mode 100644 index 35321a5a7..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/links/urlOnlyLink.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a url only link", () => { - allure.link("https://foo.bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/urlTypeLink.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/links/urlTypeLink.spec.js new file mode 100644 index 000000000..3237ccea9 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/links/urlTypeLink.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a link of a custom type", () => { + allure.link("https://foo.bar", "baz", "qux"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/links/urlTypeLink.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/links/urlTypeLink.spec.mjs deleted file mode 100644 index ddf1a9e73..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/links/urlTypeLink.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a link of a custom type", () => { - allure.link("https://foo.bar", "baz", "qux"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithExcludedParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithExcludedParameter.spec.js new file mode 100644 index 000000000..5ecaf905b --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithExcludedParameter.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +["bar", "baz"].forEach((v) => { + it("a test with an excluded parameter", () => { + allure.parameter("foo", v, { excluded: true }); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithExcludedParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithExcludedParameter.spec.mjs deleted file mode 100644 index 404a0b83d..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithExcludedParameter.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -["bar", "baz"].forEach((v) => { - it("a test with an excluded parameter", () => { - allure.parameter("foo", v, { excluded: true }); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithHiddenParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithHiddenParameter.spec.js new file mode 100644 index 000000000..e5f4afb6a --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithHiddenParameter.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a hidden parameter", () => { + allure.parameter("foo", "bar", { mode: "hidden" }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithHiddenParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithHiddenParameter.spec.mjs deleted file mode 100644 index 71acbc2bd..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithHiddenParameter.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a hidden parameter", () => { - allure.parameter("foo", "bar", { mode: "hidden" }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithMaskedParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithMaskedParameter.spec.js new file mode 100644 index 000000000..97678cedd --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithMaskedParameter.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a test with a masked parameter", () => { + allure.parameter("foo", "bar", { mode: "masked" }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithMaskedParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithMaskedParameter.spec.mjs deleted file mode 100644 index 3b06997b1..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithMaskedParameter.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a test with a masked parameter", () => { - allure.parameter("foo", "bar", { mode: "masked" }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithParameter.spec.js new file mode 100644 index 000000000..53eeb0534 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithParameter.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +["bar", "baz", { key: 10 }].forEach((v) => { + it("a test with a parameter", () => { + allure.parameter("foo", v); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithParameter.spec.mjs deleted file mode 100644 index 77d877be7..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/parameters/testWithParameter.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -["bar", "baz", { key: 10 }].forEach((v) => { - it("a test with a parameter", () => { - allure.parameter("foo", v); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenLogStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenLogStep.spec.js similarity index 100% rename from packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenLogStep.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenLogStep.spec.js diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenStep.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenStep.spec.js new file mode 100644 index 000000000..56b1234a0 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenStep.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a broken step", () => { + allure.step("foo", () => { + throw new Error("foo"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenStep.spec.mjs deleted file mode 100644 index 9bdff6041..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/steps/brokenStep.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a broken step", () => { - allure.step("foo", () => { - throw new Error("foo"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/failedStep.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/steps/failedStep.spec.js new file mode 100644 index 000000000..044a1d048 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/steps/failedStep.spec.js @@ -0,0 +1,12 @@ +// cjs: const { expect } = require("chai"); +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { expect } from "chai"; +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a failed step", () => { + allure.step("foo", () => { + expect("foo").eq("bar", "baz"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/failedStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/failedStep.spec.mjs deleted file mode 100644 index 039a55e65..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/steps/failedStep.spec.mjs +++ /dev/null @@ -1,9 +0,0 @@ -import { expect } from "chai"; -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a failed step", () => { - allure.step("foo", () => { - expect("foo").eq("bar", "baz"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/lambdaStep.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/steps/lambdaStep.spec.js new file mode 100644 index 000000000..7a5763aba --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/steps/lambdaStep.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a lambda step", () => { + allure.step("foo", () => {}); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/lambdaStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/lambdaStep.spec.mjs deleted file mode 100644 index db8009636..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/steps/lambdaStep.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a lambda step", () => { - allure.step("foo", () => {}); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/logStep.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/steps/logStep.spec.js new file mode 100644 index 000000000..21fa29462 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/steps/logStep.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a passed log step", () => { + allure.logStep("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/logStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/logStep.spec.mjs deleted file mode 100644 index dd82a3785..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/steps/logStep.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a log step", () => { - allure.step("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/renamedStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/renamedStep.spec.js similarity index 100% rename from packages/allure-mocha/test/fixtures/samples/legacy/steps/renamedStep.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/legacy/steps/renamedStep.spec.js diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/skippedLogStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/skippedLogStep.spec.js similarity index 100% rename from packages/allure-mocha/test/fixtures/samples/legacy/steps/skippedLogStep.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/legacy/steps/skippedLogStep.spec.js diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepReturnsPromise.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepReturnsPromise.spec.js similarity index 100% rename from packages/allure-mocha/test/fixtures/samples/legacy/steps/stepReturnsPromise.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/legacy/steps/stepReturnsPromise.spec.js diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepReturnsValue.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepReturnsValue.spec.js similarity index 100% rename from packages/allure-mocha/test/fixtures/samples/legacy/steps/stepReturnsValue.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/legacy/steps/stepReturnsValue.spec.js diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithAttachment.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithAttachment.spec.js new file mode 100644 index 000000000..697f0a896 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithAttachment.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("a step with an attachment", () => { + allure.step("step", () => { + allure.attachment("foo.txt", Buffer.from("bar"), "text/plain"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithAttachment.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithAttachment.spec.mjs deleted file mode 100644 index e78a4ce50..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithAttachment.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("a step with an attachment", () => { - allure.step("step", () => { - allure.attachment("foo.txt", Buffer.from("bar"), "text/plain"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithParameter.spec.js similarity index 100% rename from packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithParameter.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/legacy/steps/stepWithParameter.spec.js diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoNestedSteps.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoNestedSteps.spec.js new file mode 100644 index 000000000..e7b294c4e --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoNestedSteps.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("two nested steps", () => { + allure.step("foo", () => { + allure.step("bar", () => {}); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoNestedSteps.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoNestedSteps.spec.mjs deleted file mode 100644 index 3855e68f3..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoNestedSteps.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("two nested steps", () => { - allure.step("foo", () => { - allure.step("bar", () => {}); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoStepsInRow.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoStepsInRow.spec.js new file mode 100644 index 000000000..114c358c8 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoStepsInRow.spec.js @@ -0,0 +1,9 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("two steps in a row", () => { + allure.step("foo", () => {}); + allure.step("bar", () => {}); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoStepsInRow.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoStepsInRow.spec.mjs deleted file mode 100644 index a44692b60..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/steps/twoStepsInRow.spec.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("two steps in a row", () => { - allure.step("foo", () => {}); - allure.step("bar", () => {}); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/testAttachment.spec.js b/packages/allure-mocha/test/fixtures/samples/legacy/testAttachment.spec.js new file mode 100644 index 000000000..4a697ed68 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/legacy/testAttachment.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { allure } = require("allure-mocha/runtime"); +// esm: import { it } from "mocha"; +// esm: import { allure } from "allure-mocha/runtime"; + +it("test attachment", () => { + allure.attachment("foo.txt", Buffer.from("bar"), "text/plain"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/testAttachment.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/testAttachment.spec.mjs deleted file mode 100644 index f1f13d36f..000000000 --- a/packages/allure-mocha/test/fixtures/samples/legacy/testAttachment.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { allure } from "allure-mocha/runtime"; - -it("test attachment", () => { - allure.attachment("foo.txt", Buffer.from("bar"), "text/plain"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/legacy/testAttachmentFromStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/legacy/testAttachmentFromStep.spec.js similarity index 100% rename from packages/allure-mocha/test/fixtures/samples/legacy/testAttachmentFromStep.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/legacy/testAttachmentFromStep.spec.js diff --git a/packages/allure-mocha/test/fixtures/samples/links/customTypeLink.spec.js b/packages/allure-mocha/test/fixtures/samples/links/customTypeLink.spec.js new file mode 100644 index 000000000..b002967ab --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/links/customTypeLink.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { link } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { link } from "allure-js-commons"; + +it("a test with a link of a custom type", async () => { + await link("https://foo.bar", "baz", "qux"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/multipleLinks.spec.mjs b/packages/allure-mocha/test/fixtures/samples/links/multipleLinks.spec.js similarity index 55% rename from packages/allure-mocha/test/fixtures/samples/links/multipleLinks.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/links/multipleLinks.spec.js index 2b56e9f83..b2eab758e 100644 --- a/packages/allure-mocha/test/fixtures/samples/links/multipleLinks.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/links/multipleLinks.spec.js @@ -1,5 +1,7 @@ -import { it } from "mocha"; -import { links } from "allure-js-commons"; +// cjs: const { it } = require("mocha"); +// cjs: const { links } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { links } from "allure-js-commons"; it("a test with two links", async () => { await links( diff --git a/packages/allure-mocha/test/fixtures/samples/links/namedIssue.spec.js b/packages/allure-mocha/test/fixtures/samples/links/namedIssue.spec.js new file mode 100644 index 000000000..0c09b2ab1 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/links/namedIssue.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { issue } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { issue } from "allure-js-commons"; + +it("a test with a named issue link", async () => { + await issue("https://foo.bar", "baz"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/namedIssue.spec.mjs b/packages/allure-mocha/test/fixtures/samples/links/namedIssue.spec.mjs deleted file mode 100644 index 21c1d1a5c..000000000 --- a/packages/allure-mocha/test/fixtures/samples/links/namedIssue.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { issue } from "allure-js-commons"; - -it("a test with a named issue link", async () => { - await issue("https://foo.bar", "baz"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/namedLink.spec.js b/packages/allure-mocha/test/fixtures/samples/links/namedLink.spec.js new file mode 100644 index 000000000..658903dc6 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/links/namedLink.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { link } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { link } from "allure-js-commons"; + +it("a test with a named link", async () => { + await link("https://foo.bar", "baz"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/namedLink.spec.mjs b/packages/allure-mocha/test/fixtures/samples/links/namedLink.spec.mjs deleted file mode 100644 index c66ece5f3..000000000 --- a/packages/allure-mocha/test/fixtures/samples/links/namedLink.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { link } from "allure-js-commons"; - -it("a test with a named link", async () => { - await link("https://foo.bar", "baz"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/namedTms.spec.js b/packages/allure-mocha/test/fixtures/samples/links/namedTms.spec.js new file mode 100644 index 000000000..5e120631c --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/links/namedTms.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { tms } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { tms } from "allure-js-commons"; + +it("a test with a named tms link", async () => { + await tms("https://foo.bar", "baz"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/namedTms.spec.mjs b/packages/allure-mocha/test/fixtures/samples/links/namedTms.spec.mjs deleted file mode 100644 index fecdab8d2..000000000 --- a/packages/allure-mocha/test/fixtures/samples/links/namedTms.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { tms } from "allure-js-commons"; - -it("a test with a named tms link", async () => { - await tms("https://foo.bar", "baz"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/urlOnlyIssue.spec.js b/packages/allure-mocha/test/fixtures/samples/links/urlOnlyIssue.spec.js new file mode 100644 index 000000000..18314391e --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/links/urlOnlyIssue.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { issue } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { issue } from "allure-js-commons"; + +it("a test with a url only issue link", async () => { + await issue("https://foo.bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/urlOnlyIssue.spec.mjs b/packages/allure-mocha/test/fixtures/samples/links/urlOnlyIssue.spec.mjs deleted file mode 100644 index 73528af0d..000000000 --- a/packages/allure-mocha/test/fixtures/samples/links/urlOnlyIssue.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { issue } from "allure-js-commons"; - -it("a test with a url only issue link", async () => { - await issue("https://foo.bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/urlOnlyLink.spec.js b/packages/allure-mocha/test/fixtures/samples/links/urlOnlyLink.spec.js new file mode 100644 index 000000000..1ae088443 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/links/urlOnlyLink.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { link } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { link } from "allure-js-commons"; + +it("a test with a url only link", async () => { + await link("https://foo.bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/urlOnlyLink.spec.mjs b/packages/allure-mocha/test/fixtures/samples/links/urlOnlyLink.spec.mjs deleted file mode 100644 index 96aad8c4d..000000000 --- a/packages/allure-mocha/test/fixtures/samples/links/urlOnlyLink.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { link } from "allure-js-commons"; - -it("a test with a url only link", async () => { - await link("https://foo.bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/urlOnlyTms.spec.js b/packages/allure-mocha/test/fixtures/samples/links/urlOnlyTms.spec.js new file mode 100644 index 000000000..e5e8bbb63 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/links/urlOnlyTms.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { tms } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { tms } from "allure-js-commons"; + +it("a test with a url only tms link", async () => { + await tms("https://foo.bar"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/urlOnlyTms.spec.mjs b/packages/allure-mocha/test/fixtures/samples/links/urlOnlyTms.spec.mjs deleted file mode 100644 index 677ec02c7..000000000 --- a/packages/allure-mocha/test/fixtures/samples/links/urlOnlyTms.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { tms } from "allure-js-commons"; - -it("a test with a url only tms link", async () => { - await tms("https://foo.bar"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/links/urlTypeLink.spec.mjs b/packages/allure-mocha/test/fixtures/samples/links/urlTypeLink.spec.mjs deleted file mode 100644 index 078d7553b..000000000 --- a/packages/allure-mocha/test/fixtures/samples/links/urlTypeLink.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { link } from "allure-js-commons"; - -it("a test with a link of a custom type", async () => { - await link("https://foo.bar", "baz", "qux"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/parameters/testWithExcludedParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/parameters/testWithExcludedParameter.spec.js new file mode 100644 index 000000000..03c1abcee --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/parameters/testWithExcludedParameter.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { parameter } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { parameter } from "allure-js-commons"; + +["bar", "baz"].forEach((v) => { + it("a test with an excluded parameter", async () => { + await parameter("foo", v, { excluded: true }); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/parameters/testWithExcludedParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/parameters/testWithExcludedParameter.spec.mjs deleted file mode 100644 index 1de1dd49d..000000000 --- a/packages/allure-mocha/test/fixtures/samples/parameters/testWithExcludedParameter.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { parameter } from "allure-js-commons"; - -["bar", "baz"].forEach((v) => { - it("a test with an excluded parameter", async () => { - await parameter("foo", v, { excluded: true }); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/parameters/testWithHiddenParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/parameters/testWithHiddenParameter.spec.js new file mode 100644 index 000000000..49d9deeb2 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/parameters/testWithHiddenParameter.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { parameter } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { parameter } from "allure-js-commons"; + +it("a test with a hidden parameter", async () => { + await parameter("foo", "bar", { mode: "hidden" }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/parameters/testWithHiddenParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/parameters/testWithHiddenParameter.spec.mjs deleted file mode 100644 index 6e625d2ef..000000000 --- a/packages/allure-mocha/test/fixtures/samples/parameters/testWithHiddenParameter.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { parameter } from "allure-js-commons"; - -it("a test with a hidden parameter", async () => { - await parameter("foo", "bar", { mode: "hidden" }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/parameters/testWithMaskedParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/parameters/testWithMaskedParameter.spec.js new file mode 100644 index 000000000..497d7fa9d --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/parameters/testWithMaskedParameter.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { parameter } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { parameter } from "allure-js-commons"; + +it("a test with a masked parameter", async () => { + await parameter("foo", "bar", { mode: "masked" }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/parameters/testWithMaskedParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/parameters/testWithMaskedParameter.spec.mjs deleted file mode 100644 index 07869a2d5..000000000 --- a/packages/allure-mocha/test/fixtures/samples/parameters/testWithMaskedParameter.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { parameter } from "allure-js-commons"; - -it("a test with a masked parameter", async () => { - await parameter("foo", "bar", { mode: "masked" }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/parameters/testWithParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/parameters/testWithParameter.spec.js new file mode 100644 index 000000000..05ac19222 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/parameters/testWithParameter.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { parameter } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { parameter } from "allure-js-commons"; + +["bar", "baz"].forEach((v) => { + it("a test with a parameter", async () => { + await parameter("foo", v); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/parameters/testWithParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/parameters/testWithParameter.spec.mjs deleted file mode 100644 index 468e1e3cd..000000000 --- a/packages/allure-mocha/test/fixtures/samples/parameters/testWithParameter.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { parameter } from "allure-js-commons"; - -["bar", "baz"].forEach((v) => { - it("a test with a parameter", async () => { - await parameter("foo", v); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/brokenTest.spec.js b/packages/allure-mocha/test/fixtures/samples/plain-mocha/brokenTest.spec.js new file mode 100644 index 000000000..a26bc0b4c --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/plain-mocha/brokenTest.spec.js @@ -0,0 +1,6 @@ +// cjs: const { it } = require("mocha"); +// esm: import { it } from "mocha"; + +it("a broken test", async () => { + throw new Error("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/brokenTest.spec.mjs b/packages/allure-mocha/test/fixtures/samples/plain-mocha/brokenTest.spec.mjs deleted file mode 100644 index 8ada6e833..000000000 --- a/packages/allure-mocha/test/fixtures/samples/plain-mocha/brokenTest.spec.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import { it } from "mocha"; - -it("a broken test", async () => { - throw new Error("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/failedTest.spec.js b/packages/allure-mocha/test/fixtures/samples/plain-mocha/failedTest.spec.js new file mode 100644 index 000000000..ac30ee4be --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/plain-mocha/failedTest.spec.js @@ -0,0 +1,8 @@ +// cjs: const { expect } = require("chai"); +// cjs: const { it } = require("mocha"); +// esm: import { expect } from "chai"; +// esm: import { it } from "mocha"; + +it("a failed test", async () => { + expect("foo").eq("bar", "baz"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/failedTest.spec.mjs b/packages/allure-mocha/test/fixtures/samples/plain-mocha/failedTest.spec.mjs deleted file mode 100644 index 8d26f2b80..000000000 --- a/packages/allure-mocha/test/fixtures/samples/plain-mocha/failedTest.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { expect } from "chai"; -import { it } from "mocha"; - -it("a failed test", async () => { - expect("foo").eq("bar", "baz"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/skippedTest.spec.js b/packages/allure-mocha/test/fixtures/samples/plain-mocha/skippedTest.spec.js new file mode 100644 index 000000000..088759807 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/plain-mocha/skippedTest.spec.js @@ -0,0 +1,4 @@ +// cjs: const { it } = require("mocha"); +// esm: import { it } from "mocha"; + +it.skip("a skipped test", async () => {}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/skippedTest.spec.mjs b/packages/allure-mocha/test/fixtures/samples/plain-mocha/skippedTest.spec.mjs deleted file mode 100644 index f34274a12..000000000 --- a/packages/allure-mocha/test/fixtures/samples/plain-mocha/skippedTest.spec.mjs +++ /dev/null @@ -1,3 +0,0 @@ -import { it } from "mocha"; - -it.skip("a skipped test", async () => {}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFileScope.spec.js b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFileScope.spec.js new file mode 100644 index 000000000..517e7da37 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFileScope.spec.js @@ -0,0 +1,4 @@ +// cjs: const { it } = require("mocha"); +// esm: import { it } from "mocha"; + +it("a test in a file scope", async () => {}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFileScope.spec.mjs b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFileScope.spec.mjs deleted file mode 100644 index 06e0bb311..000000000 --- a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFileScope.spec.mjs +++ /dev/null @@ -1,3 +0,0 @@ -import { it } from "mocha"; - -it("a test in a file scope", async () => {}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFourSuites.spec.mjs b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFourSuites.spec.js similarity index 68% rename from packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFourSuites.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFourSuites.spec.js index 43a87a463..59e9cf423 100644 --- a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFourSuites.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInFourSuites.spec.js @@ -1,4 +1,5 @@ -import { describe, it } from "mocha"; +// cjs: const { describe, it } = require("mocha"); +// esm: import { describe, it } from "mocha"; describe("foo", async () => { describe("bar", async () => { diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInSuite.spec.mjs b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInSuite.spec.js similarity index 50% rename from packages/allure-mocha/test/fixtures/samples/plain-mocha/testInSuite.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/plain-mocha/testInSuite.spec.js index c12743581..d9192e615 100644 --- a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInSuite.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInSuite.spec.js @@ -1,4 +1,5 @@ -import { it } from "mocha"; +// cjs: const { it } = require("mocha"); +// esm: import { it } from "mocha"; describe("foo", async () => { it("a test in a suite", async () => {}); diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInThreeSuites.spec.mjs b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInThreeSuites.spec.js similarity index 63% rename from packages/allure-mocha/test/fixtures/samples/plain-mocha/testInThreeSuites.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/plain-mocha/testInThreeSuites.spec.js index 0cf92efc9..c6c86c30a 100644 --- a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInThreeSuites.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInThreeSuites.spec.js @@ -1,4 +1,5 @@ -import { describe, it } from "mocha"; +// cjs: const { describe, it } = require("mocha"); +// esm: import { describe, it } from "mocha"; describe("foo", async () => { describe("bar", async () => { diff --git a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInTwoSuites.spec.mjs b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInTwoSuites.spec.js similarity index 61% rename from packages/allure-mocha/test/fixtures/samples/plain-mocha/testInTwoSuites.spec.mjs rename to packages/allure-mocha/test/fixtures/samples/plain-mocha/testInTwoSuites.spec.js index 26507f8f6..0d45ce70a 100644 --- a/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInTwoSuites.spec.mjs +++ b/packages/allure-mocha/test/fixtures/samples/plain-mocha/testInTwoSuites.spec.js @@ -1,4 +1,5 @@ -import { it } from "mocha"; +// cjs: const { it } = require("mocha"); +// esm: import { it } from "mocha"; describe("foo", async () => { describe("bar", async () => { diff --git a/packages/allure-mocha/test/fixtures/samples/steps/brokenStep.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/brokenStep.spec.js new file mode 100644 index 000000000..6e9e11da5 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/brokenStep.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a broken step", async () => { + await step("foo", async () => { + throw new Error("foo"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/brokenStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/brokenStep.spec.mjs deleted file mode 100644 index a534308d8..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/brokenStep.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("a broken step", async () => { - await step("foo", async () => { - throw new Error("foo"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/failedStep.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/failedStep.spec.js new file mode 100644 index 000000000..07825c2db --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/failedStep.spec.js @@ -0,0 +1,12 @@ +// cjs: const { expect } = require("chai"); +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { expect } from "chai"; +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a failed step", async () => { + await step("foo", async () => { + expect("foo").eq("bar", "baz"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/failedStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/failedStep.spec.mjs deleted file mode 100644 index ce958d027..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/failedStep.spec.mjs +++ /dev/null @@ -1,9 +0,0 @@ -import { expect } from "chai"; -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("a failed step", async () => { - await step("foo", async () => { - expect("foo").eq("bar", "baz"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/lambdaStep.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/lambdaStep.spec.js new file mode 100644 index 000000000..e35fcad56 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/lambdaStep.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a lambda step", async () => { + await step("foo", async () => {}); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/lambdaStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/lambdaStep.spec.mjs deleted file mode 100644 index c24947fda..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/lambdaStep.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("a lambda step", async () => { - await step("foo", async () => {}); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/logStep.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/logStep.spec.js new file mode 100644 index 000000000..57ef06da3 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/logStep.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a log step", async () => { + await step("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/logStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/logStep.spec.mjs deleted file mode 100644 index 846b8b32e..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/logStep.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("a log step", async () => { - await step("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/renamedStep.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/renamedStep.spec.js new file mode 100644 index 000000000..fef5abe53 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/renamedStep.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a renamed step", async () => { + await step("foo", async (ctx) => { + await ctx.displayName("bar"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/renamedStep.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/renamedStep.spec.mjs deleted file mode 100644 index 49df6065a..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/renamedStep.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("a renamed step", async () => { - await step("foo", async (ctx) => { - await ctx.displayName("bar"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepReturnsPromise.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/stepReturnsPromise.spec.js new file mode 100644 index 000000000..f885fcb86 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/stepReturnsPromise.spec.js @@ -0,0 +1,11 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a test with a step that returns a value promise", async () => { + const result = await step("foo", async () => await new Promise((r) => setTimeout(() => r("bar"), 50))); + if (result !== "bar") { + throw new Error(`Unexpected value ${result}`); + } +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepReturnsValue.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/stepReturnsValue.spec.js new file mode 100644 index 000000000..5f8155c2d --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/stepReturnsValue.spec.js @@ -0,0 +1,11 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a test with a step that returns a value", async () => { + const result = await step("foo", () => "bar"); + if (result !== "bar") { + throw new Error(`Unexpected value ${result}`); + } +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepWithAttachment.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/stepWithAttachment.spec.js new file mode 100644 index 000000000..4eaf7902e --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/stepWithAttachment.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { attachment, step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { attachment, step } from "allure-js-commons"; + +it("a step with an attachment", async () => { + await step("step", async () => { + await attachment("foo.txt", Buffer.from("bar"), "text/plain"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepWithAttachment.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/stepWithAttachment.spec.mjs deleted file mode 100644 index 3a904e540..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/stepWithAttachment.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { attachment, step } from "allure-js-commons"; - -it("a step with an attachment", async () => { - await step("step", async () => { - await attachment("foo.txt", Buffer.from("bar"), "text/plain"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepWithHiddenParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/stepWithHiddenParameter.spec.js new file mode 100644 index 000000000..c0cdef83c --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/stepWithHiddenParameter.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a step with a hidden parameter", async () => { + await step("foo", async (ctx) => { + await ctx.parameter("bar", "baz", "hidden"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepWithHiddenParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/stepWithHiddenParameter.spec.mjs deleted file mode 100644 index cd732ce98..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/stepWithHiddenParameter.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("a step with a hidden parameter", async () => { - await step("foo", async (ctx) => { - ctx.parameter("bar", "baz", "hidden"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepWithMaskedParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/stepWithMaskedParameter.spec.js new file mode 100644 index 000000000..5373c0e43 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/stepWithMaskedParameter.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a step with a masked parameter", async () => { + await step("foo", async (ctx) => { + await ctx.parameter("bar", "baz", "masked"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepWithMaskedParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/stepWithMaskedParameter.spec.mjs deleted file mode 100644 index 0575c9da4..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/stepWithMaskedParameter.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("a step with a masked parameter", async () => { - await step("foo", async (ctx) => { - ctx.parameter("bar", "baz", "masked"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepWithParameter.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/stepWithParameter.spec.js new file mode 100644 index 000000000..07a09cfc8 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/stepWithParameter.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("a step with a parameter", async () => { + await step("foo", async (ctx) => { + await ctx.parameter("bar", "baz"); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/stepWithParameter.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/stepWithParameter.spec.mjs deleted file mode 100644 index 70044a5f5..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/stepWithParameter.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("a step with a parameter", async () => { - await step("foo", async (ctx) => { - ctx.parameter("bar", "baz"); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/twoNestedSteps.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/twoNestedSteps.spec.js new file mode 100644 index 000000000..ebdd09f7d --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/twoNestedSteps.spec.js @@ -0,0 +1,10 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("two nested steps", async () => { + await step("foo", async () => { + await step("bar", async () => {}); + }); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/twoNestedSteps.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/twoNestedSteps.spec.mjs deleted file mode 100644 index 2e4ab2ea6..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/twoNestedSteps.spec.mjs +++ /dev/null @@ -1,8 +0,0 @@ -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("two nested steps", async () => { - await step("foo", async () => { - await step("bar", async () => {}); - }); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/twoStepsInRow.spec.js b/packages/allure-mocha/test/fixtures/samples/steps/twoStepsInRow.spec.js new file mode 100644 index 000000000..019a71b96 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/steps/twoStepsInRow.spec.js @@ -0,0 +1,9 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { step } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { step } from "allure-js-commons"; + +it("two steps in a row", async () => { + await step("foo", async () => {}); + await step("bar", async () => {}); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/steps/twoStepsInRow.spec.mjs b/packages/allure-mocha/test/fixtures/samples/steps/twoStepsInRow.spec.mjs deleted file mode 100644 index cea1ab5bd..000000000 --- a/packages/allure-mocha/test/fixtures/samples/steps/twoStepsInRow.spec.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { it } from "mocha"; -import { step } from "allure-js-commons"; - -it("two steps in a row", async () => { - await step("foo", async () => {}); - await step("bar", async () => {}); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/testAttachment.spec.js b/packages/allure-mocha/test/fixtures/samples/testAttachment.spec.js new file mode 100644 index 000000000..45d2ff092 --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/testAttachment.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { attachment } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { attachment } from "allure-js-commons"; + +it("test attachment", async () => { + await attachment("foo.txt", Buffer.from("bar"), "text/plain"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/testAttachment.spec.mjs b/packages/allure-mocha/test/fixtures/samples/testAttachment.spec.mjs deleted file mode 100644 index df1358c57..000000000 --- a/packages/allure-mocha/test/fixtures/samples/testAttachment.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { attachment } from "allure-js-commons"; - -it("test attachment", async () => { - await attachment("foo.txt", Buffer.from("bar"), "text/plain"); -}); diff --git a/packages/allure-mocha/test/fixtures/samples/testDisplayName.spec.js b/packages/allure-mocha/test/fixtures/samples/testDisplayName.spec.js new file mode 100644 index 000000000..c498b9ecd --- /dev/null +++ b/packages/allure-mocha/test/fixtures/samples/testDisplayName.spec.js @@ -0,0 +1,8 @@ +// cjs: const { it } = require("mocha"); +// cjs: const { displayName } = require("allure-js-commons"); +// esm: import { it } from "mocha"; +// esm: import { displayName } from "allure-js-commons"; + +it("a renamed test", async () => { + await displayName("foo"); +}); diff --git a/packages/allure-mocha/test/fixtures/samples/testDisplayName.spec.mjs b/packages/allure-mocha/test/fixtures/samples/testDisplayName.spec.mjs deleted file mode 100644 index 08d9a9337..000000000 --- a/packages/allure-mocha/test/fixtures/samples/testDisplayName.spec.mjs +++ /dev/null @@ -1,6 +0,0 @@ -import { it } from "mocha"; -import { displayName } from "allure-js-commons"; - -it("a renamed test", async () => { - await displayName("foo"); -}); diff --git a/packages/allure-mocha/test/fixtures/setupParallel.cjs b/packages/allure-mocha/test/fixtures/setupParallel.cjs index 573ebae37..f031fd03d 100644 --- a/packages/allure-mocha/test/fixtures/setupParallel.cjs +++ b/packages/allure-mocha/test/fixtures/setupParallel.cjs @@ -1,10 +1,8 @@ -/* eslint @typescript-eslint/no-require-imports: 0 */ -/* eslint @typescript-eslint/no-var-requires: 0 */ /* eslint no-underscore-dangle: 0 */ const { BufferedWorkerPool } = require("mocha/lib/nodejs/buffered-worker-pool.js"); +const ParallelBuffered = require("mocha/lib/nodejs/reporters/parallel-buffered.js"); const process = require("process"); const path = require("path"); - let poolClassPatched = false; let workerClassPatched = false; @@ -73,19 +71,32 @@ const patchPool = () => { BufferedWorkerPool.create = createPatchedPoolCreate(BufferedWorkerPool.create); }; -const ensurePoolPatched = () => { +const patchLeader = () => { if (!poolClassPatched) { patchPool(); poolClassPatched = true; } }; -const shouldPatchPool = () => !process.connected || process.ppid.toString() === process.env.ALLURE_MOCHA_TESTHOST_PID; +const patchWorker = () => { + const originalCreateListeners = ParallelBuffered.prototype.createListeners; + ParallelBuffered.prototype.createListeners = function (runner) { + const writer = this.options.reporterOptions?.writer; + if (writer === "MessageWriter") { + this.options.reporterOptions.writer = require("./AllureMochaParallelWriter.cjs"); + } + return originalCreateListeners.call(this, runner); + }; +}; -const patchLeader = () => { - if (shouldPatchPool()) { - ensurePoolPatched(); +const shouldPatchLeader = () => !process.connected || process.ppid.toString() === process.env.ALLURE_MOCHA_TESTHOST_PID; + +const patch = () => { + if (shouldPatchLeader()) { + patchLeader(); + } else { + patchWorker(); } }; -patchLeader(); +patch(); diff --git a/packages/allure-mocha/test/spec/api/globalLabels.test.ts b/packages/allure-mocha/test/spec/api/globalLabels.test.ts index 61bbaa1f9..0a2a96abe 100644 --- a/packages/allure-mocha/test/spec/api/globalLabels.test.ts +++ b/packages/allure-mocha/test/spec/api/globalLabels.test.ts @@ -1,6 +1,5 @@ import { beforeAll, describe, expect, it } from "vitest"; import type { Label } from "allure-js-commons"; -import { LabelName } from "allure-js-commons"; import { runMochaInlineTest } from "../../utils.js"; describe("env labels", () => { @@ -35,20 +34,11 @@ describe("env labels", () => { expect(labels).toContainEqual({ name: "workerId", value: "baz" }); }); - it("adds non-empty labels from environment variables", () => { - expect(labels).toMatchObject( - expect.arrayContaining([ - { name: "B", value: "foo" }, - { name: "b", value: "bar" }, - ]), - ); - }); - it("global label takes precedence over the initial one", () => { expect(labels).toMatchObject( expect.arrayContaining([ - { name: LabelName.LANGUAGE, value: "foobar" }, - { name: LabelName.LANGUAGE, value: "javascript" }, + { name: "language", value: "foobar" }, + { name: "language", value: "javascript" }, ]), ); }); diff --git a/packages/allure-mocha/test/spec/api/runtime/attachments.test.ts b/packages/allure-mocha/test/spec/api/runtime/attachments.test.ts index 959933246..7d274e076 100644 --- a/packages/allure-mocha/test/spec/api/runtime/attachments.test.ts +++ b/packages/allure-mocha/test/spec/api/runtime/attachments.test.ts @@ -1,4 +1,5 @@ import { beforeAll, describe, expect, it } from "vitest"; +import type { TestResult } from "allure-js-commons"; import type { AllureResults } from "allure-js-commons/sdk"; import { runMochaInlineTest } from "../../../utils.js"; @@ -9,7 +10,7 @@ describe("test attachments", () => { }); it("test may contain an attachment", () => { - const testResult = results.tests.find((t) => t.name === "test attachment")!; + const testResult = results.tests.find((t: TestResult) => t.name === "test attachment")!; const [step] = testResult.steps; expect(step.name).toBe("foo.txt"); diff --git a/packages/allure-mocha/test/spec/api/runtime/legacy/attachments.test.ts b/packages/allure-mocha/test/spec/api/runtime/legacy/attachments.test.ts index 015956445..a1368f36d 100644 --- a/packages/allure-mocha/test/spec/api/runtime/legacy/attachments.test.ts +++ b/packages/allure-mocha/test/spec/api/runtime/legacy/attachments.test.ts @@ -1,15 +1,16 @@ import { beforeAll, describe, expect, it } from "vitest"; +import type { TestResult } from "allure-js-commons"; import type { AllureResults } from "allure-js-commons/sdk"; import { runMochaInlineTest } from "../../../../utils.js"; describe("legacy test attachments API", () => { let results: AllureResults; beforeAll(async () => { - results = await runMochaInlineTest(["legacy", "testAttachment"]); + results = await runMochaInlineTest(["legacy", "testAttachment"], ["legacy", "testAttachmentFromStep"]); }); it("test may contain an attachment", () => { - const testResult = results.tests.find((t) => t.name === "test attachment")!; + const testResult = results.tests.find((t: TestResult) => t.name === "test attachment")!; const [step] = testResult.steps; expect(step.name).toBe("foo.txt"); diff --git a/packages/allure-mocha/test/spec/api/runtime/legacy/extraFiles.test.ts b/packages/allure-mocha/test/spec/api/runtime/legacy/extraFiles.test.ts new file mode 100644 index 000000000..5187a9c3d --- /dev/null +++ b/packages/allure-mocha/test/spec/api/runtime/legacy/extraFiles.test.ts @@ -0,0 +1,34 @@ +import { beforeAll, describe, expect, it } from "vitest"; +import { Status } from "allure-js-commons"; +import { runMochaInlineTest } from "../../../../utils.js"; + +describe("legacy extra files API", () => { + let envInfo: unknown, categories: unknown; + beforeAll(async () => { + ({ envInfo, categories } = await runMochaInlineTest(["legacy", "environmentInfo"], ["legacy", "categories"])); + }); + + it("the run should have an environment info", () => { + expect(envInfo).toMatchObject({ + foo: "bar", + baz: "qux", + }); + }); + + it("the run should have categories", () => { + expect(categories).toEqual([ + { + name: "foo", + description: "bar", + messageRegex: "broken", + matchedStatuses: [Status.BROKEN], + }, + { + name: "baz", + description: "qux", + messageRegex: "failure", + matchedStatuses: [Status.FAILED], + }, + ]); + }); +}); diff --git a/packages/allure-mocha/test/spec/api/runtime/legacy/parameters.test.ts b/packages/allure-mocha/test/spec/api/runtime/legacy/parameters.test.ts index adb9eefa6..96756501b 100644 --- a/packages/allure-mocha/test/spec/api/runtime/legacy/parameters.test.ts +++ b/packages/allure-mocha/test/spec/api/runtime/legacy/parameters.test.ts @@ -48,8 +48,7 @@ describe("legacy runtime parameters API", () => { parameters: [ { name: "foo", - // eslint-disable-next-line - value: '{"key":10}', + value: String.raw`{"key":10}`, }, ], }), diff --git a/packages/allure-mocha/test/spec/api/runtime/legacy/steps.test.ts b/packages/allure-mocha/test/spec/api/runtime/legacy/steps.test.ts new file mode 100644 index 000000000..025d59e76 --- /dev/null +++ b/packages/allure-mocha/test/spec/api/runtime/legacy/steps.test.ts @@ -0,0 +1,244 @@ +import { beforeAll, describe, expect, it } from "vitest"; +import { Stage, Status } from "allure-js-commons"; +import type { TestResult } from "allure-js-commons"; +import { runMochaInlineTest } from "../../../../utils.js"; + +describe("step", () => { + const testMap = new Map(); + let attachments: Record; + beforeAll(async () => { + const results = await runMochaInlineTest( + ["legacy", "steps", "logStep"], + ["legacy", "steps", "failedLogStep"], + ["legacy", "steps", "brokenLogStep"], + ["legacy", "steps", "skippedLogStep"], + ["legacy", "steps", "lambdaStep"], + ["legacy", "steps", "twoStepsInRow"], + ["legacy", "steps", "twoNestedSteps"], + ["legacy", "steps", "renamedStep"], + ["legacy", "steps", "failedStep"], + ["legacy", "steps", "brokenStep"], + ["legacy", "steps", "stepWithAttachment"], + ["legacy", "steps", "stepWithParameter"], + ["legacy", "steps", "stepReturnsValue"], + ["legacy", "steps", "stepReturnsPromise"], + ); + for (const testResult of results.tests) { + testMap.set(testResult.name as string, testResult as TestResult); + } + attachments = results.attachments; + }); + + describe("structure", () => { + describe("log steps", () => { + it("could be passed", () => { + expect(testMap.get("a passed log step")).toMatchObject({ + steps: [ + expect.objectContaining({ + name: "foo", + status: Status.PASSED, + }), + ], + }); + }); + + it("could be failed", () => { + expect(testMap.get("a failed log step")).toMatchObject({ + steps: [ + expect.objectContaining({ + name: "foo", + status: Status.FAILED, + }), + ], + }); + }); + + it("could be broken", () => { + expect(testMap.get("a broken log step")).toMatchObject({ + steps: [ + expect.objectContaining({ + name: "foo", + status: Status.BROKEN, + }), + ], + }); + }); + + it("could be skipped", () => { + expect(testMap.get("a skipped log step")).toMatchObject({ + steps: [ + expect.objectContaining({ + name: "foo", + status: Status.SKIPPED, + }), + ], + }); + }); + }); + + it("lambda", () => { + expect(testMap.get("a lambda step")).toMatchObject({ + steps: [ + expect.objectContaining({ + name: "foo", + }), + ], + }); + }); + + it("serial steps", () => { + expect(testMap.get("two steps in a row")).toMatchObject({ + steps: [expect.objectContaining({ name: "foo" }), expect.objectContaining({ name: "bar" })], + }); + }); + + it("nested steps", () => { + expect(testMap.get("two nested steps")).toMatchObject({ + steps: [ + expect.objectContaining({ + name: "foo", + steps: [expect.objectContaining({ name: "bar" })], + }), + ], + }); + }); + }); + + describe("timings", () => { + it("for serial tests match", () => { + const test = testMap.get("two steps in a row")!; + const [firstStep, secondStep] = test.steps; + const timestamps = [ + test.start!, + firstStep.start!, + firstStep.stop!, + secondStep.start!, + secondStep.stop!, + test.stop!, + ]; + expect(timestamps).toEqual([...timestamps].sort()); + }); + + it("for nested tests match", () => { + const test = testMap.get("two nested steps")!; + const [firstStep] = test.steps; + const [secondStep] = firstStep.steps; + const timestamps = [ + test.start!, + firstStep.start!, + secondStep.start!, + secondStep.stop!, + firstStep.stop!, + test.stop!, + ]; + expect(timestamps).toEqual([...timestamps].sort()); + }); + }); + + describe("status", () => { + it("could be passed", () => { + expect(testMap.get("a lambda step")).toMatchObject({ + status: Status.PASSED, + stage: Stage.FINISHED, + steps: [ + expect.objectContaining({ + status: Status.PASSED, + stage: Stage.FINISHED, + }), + ], + }); + }); + + it("could be failed", () => { + expect(testMap.get("a failed step")).toMatchObject({ + status: Status.FAILED, + stage: Stage.FINISHED, + statusDetails: { + message: "baz: expected 'foo' to equal 'bar'", + trace: expect.stringMatching(/.+/), + }, + steps: [ + expect.objectContaining({ + status: Status.FAILED, + stage: Stage.FINISHED, + statusDetails: { + message: "baz: expected 'foo' to equal 'bar'", + trace: expect.stringMatching(/.+/), + }, + }), + ], + }); + }); + + it("could be broken", () => { + expect(testMap.get("a broken step")).toMatchObject({ + status: Status.BROKEN, + stage: Stage.FINISHED, + statusDetails: { + message: "foo", + trace: expect.stringMatching(/.+/), + }, + steps: [ + expect.objectContaining({ + status: Status.BROKEN, + stage: Stage.FINISHED, + statusDetails: { + message: "foo", + trace: expect.stringMatching(/.+/), + }, + }), + ], + }); + }); + }); + + describe("step that return values", () => { + it("may return a plain value", () => { + expect(testMap.get("a test with a step that returns a value")).toMatchObject({ + status: Status.PASSED, + }); + }); + + it("may return a promised", () => { + expect(testMap.get("a test with a step that returns a value promise")).toMatchObject({ + status: Status.PASSED, + }); + }); + }); + + it("can be renamed", () => { + expect(testMap.get("a test with a renamed step")).toMatchObject({ + steps: [ + expect.objectContaining({ + name: "bar", + }), + ], + }); + }); + + it("may contain an attachment", () => { + const [substep] = testMap.get("a step with an attachment")?.steps[0]?.steps ?? []; + + expect(substep.name).toEqual("foo.txt"); + expect(substep.attachments).toEqual([ + expect.objectContaining({ + name: "foo.txt", + type: "text/plain", + }), + ]); + const source = substep.attachments[0].source; + const contentInBase64 = attachments[source] as string; + const decodedContent = Buffer.from(contentInBase64, "base64").toString("utf8"); + expect(decodedContent).toEqual("bar"); + }); + + it("may contain a parameter", () => { + expect(testMap.get("a step with a parameter")).toMatchObject({ + steps: expect.arrayContaining([ + expect.objectContaining({ + parameters: [{ name: "bar", value: "baz" }], + }), + ]), + }); + }); +}); diff --git a/packages/allure-mocha/test/spec/api/runtime/links.test.ts b/packages/allure-mocha/test/spec/api/runtime/links.test.ts index 373e558b7..df948d9b1 100644 --- a/packages/allure-mocha/test/spec/api/runtime/links.test.ts +++ b/packages/allure-mocha/test/spec/api/runtime/links.test.ts @@ -7,7 +7,7 @@ describe("link", () => { beforeAll(async () => { const { tests } = await runMochaInlineTest( ["links", "urlOnlyLink"], - ["links", "urlTypeLink"], + ["links", "customTypeLink"], ["links", "namedLink"], ["links", "urlOnlyIssue"], ["links", "namedIssue"], diff --git a/packages/allure-mocha/test/spec/api/runtime/steps.test.ts b/packages/allure-mocha/test/spec/api/runtime/steps.test.ts index 8d3e2ef0f..915e98bc0 100644 --- a/packages/allure-mocha/test/spec/api/runtime/steps.test.ts +++ b/packages/allure-mocha/test/spec/api/runtime/steps.test.ts @@ -1,6 +1,6 @@ import { beforeAll, describe, expect, it } from "vitest"; -import type { TestResult } from "allure-js-commons"; import { Stage, Status } from "allure-js-commons"; +import type { TestResult } from "allure-js-commons"; import { runMochaInlineTest } from "../../../utils.js"; describe("step", () => { @@ -19,6 +19,8 @@ describe("step", () => { ["steps", "stepWithParameter"], ["steps", "stepWithMaskedParameter"], ["steps", "stepWithHiddenParameter"], + ["steps", "stepReturnsValue"], + ["steps", "stepReturnsPromise"], ); for (const testResult of results.tests) { testMap.set(testResult.name as string, testResult as TestResult); @@ -153,6 +155,20 @@ describe("step", () => { }); }); + describe("step that return values", () => { + it("may return a plain value", () => { + expect(testMap.get("a test with a step that returns a value")).toMatchObject({ + status: Status.PASSED, + }); + }); + + it("may return a promised", () => { + expect(testMap.get("a test with a step that returns a value promise")).toMatchObject({ + status: Status.PASSED, + }); + }); + }); + it("can be renamed", () => { expect(testMap.get("a renamed step")).toMatchObject({ steps: [ diff --git a/packages/allure-mocha/test/spec/framework/result.test.ts b/packages/allure-mocha/test/spec/framework/result.test.ts index d4de8797c..5b2f86e45 100644 --- a/packages/allure-mocha/test/spec/framework/result.test.ts +++ b/packages/allure-mocha/test/spec/framework/result.test.ts @@ -1,6 +1,6 @@ import { beforeAll, describe, expect, it } from "vitest"; import type { TestResult } from "allure-js-commons"; -import { runMochaInlineTest } from "../../utils.js"; +import { SPEC_EXT, runMochaInlineTest } from "../../utils.js"; describe("defaults", () => { let test: TestResult; @@ -14,9 +14,8 @@ describe("defaults", () => { }); it("has fullName", () => { - expect(test.fullName).toMatch( - /^test\/fixtures\/run-results\/[0-9a-f-]+\/plain-mocha\/testInFileScope\.spec\.mjs: a test in a file scope$/, - ); + const fnPattern = new RegExp(`plain-mocha\\/testInFileScope\\.spec\\${SPEC_EXT}: a test in a file scope$`); + expect(test.fullName).toMatch(fnPattern); }); it("has historyId", () => { @@ -36,14 +35,13 @@ describe("defaults", () => { it("has default labels", () => { const labels = test.labels; + const packagePattern = new RegExp(`plain-mocha\\.testInFileScope\\.spec\\${SPEC_EXT}$`); expect(labels).toContainEqual({ name: "language", value: "javascript" }); expect(labels).toContainEqual({ name: "framework", value: "mocha" }); expect(labels).toContainEqual({ name: "host", value: expect.anything() }); expect(labels).toContainEqual({ name: "package", - value: expect.stringMatching( - /^test\.fixtures\.run-results\.[0-9a-f-]+\.plain-mocha\.testInFileScope\.spec\.mjs$/, - ), + value: expect.stringMatching(packagePattern), }); }); }); diff --git a/packages/allure-mocha/test/spec/framework/statuses.test.ts b/packages/allure-mocha/test/spec/framework/statuses.test.ts index ecb4ad996..099f07c49 100644 --- a/packages/allure-mocha/test/spec/framework/statuses.test.ts +++ b/packages/allure-mocha/test/spec/framework/statuses.test.ts @@ -1,6 +1,6 @@ import { beforeAll, describe, expect, it } from "vitest"; -import type { TestResult } from "allure-js-commons"; import { Stage, Status } from "allure-js-commons"; +import type { TestResult } from "allure-js-commons"; import { runMochaInlineTest } from "../../utils.js"; describe("test status", () => { diff --git a/packages/allure-mocha/test/utils.ts b/packages/allure-mocha/test/utils.ts index b10ebc468..de269a7ad 100644 --- a/packages/allure-mocha/test/utils.ts +++ b/packages/allure-mocha/test/utils.ts @@ -1,20 +1,175 @@ import { fork } from "node:child_process"; import { randomUUID } from "node:crypto"; import { appendFileSync } from "node:fs"; -import { copyFile, cp, mkdir, writeFile } from "node:fs/promises"; +import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises"; import * as path from "node:path"; import type { AllureResults } from "allure-js-commons/sdk"; import { MessageReader } from "allure-js-commons/sdk/reporter"; type MochaRunOptions = { env?: { [keys: string]: string }; - mode?: "serial" | "parallel"; }; +type ModuleFormat = "cjs" | "esm"; + +const getFormatExt = (format: ModuleFormat) => (format === "cjs" ? ".cjs" : ".mjs"); + +export const SPEC_FORMAT: ModuleFormat = process.env.ALLURE_MOCHA_TEST_SPEC_FORMAT === "cjs" ? "cjs" : "esm"; +export const RUNNER: "cli" | ModuleFormat = + process.env.ALLURE_MOCHA_TEST_RUNNER === "cjs" + ? "cjs" + : process.env.ALLURE_MOCHA_TEST_RUNNER === "esm" + ? "esm" + : "cli"; +export const SPEC_EXT = getFormatExt(SPEC_FORMAT); +export const RUN_IN_PARALLEL = !!process.env.ALLURE_MOCHA_TEST_PARALLEL; + +const uncommentPattern = new Map([ + ["cjs", /\/\/ cjs: ([^\r\n]+)/g], + ["esm", /\/\/ esm: ([^\r\n]+)/g], +]); + +abstract class AllureMochaTestRunner { + readonly fixturesPath: string; + readonly samplesPath: string; + readonly runResultsDir: string; + constructor(private readonly config: MochaRunOptions) { + this.fixturesPath = path.join(__dirname, "fixtures"); + this.samplesPath = path.join(this.fixturesPath, "samples"); + this.runResultsDir = path.join(this.fixturesPath, "run-results"); + } + + run = async (...samples: readonly (string | readonly string[])[]) => { + const testDir = path.join(this.runResultsDir, randomUUID()); + + const filesToCopy = [...this.getFilesToCopy(testDir)]; + const filesToTransform = [ + ...this.getFilesToTransform(testDir), + ...samples.map((sample) => this.getSampleEntry(sample, this.samplesPath, testDir)), + ]; + const scriptArgs = this.getScriptArgs(); + + if (RUN_IN_PARALLEL) { + const setupParallelCopyEntry = this.getCopyEntry("setupParallel.cjs", testDir); + filesToCopy.push(setupParallelCopyEntry, this.getCopyEntry("AllureMochaParallelWriter.cjs", testDir)); + scriptArgs.push("--parallel"); + if (RUNNER === "cli") { + scriptArgs.push("--require", setupParallelCopyEntry[1]); + } + } + + const scriptPath = this.getScriptPath(testDir); + const cmdPath = path.join(testDir, "cmd.log"); + const cmdContent = [scriptPath, ...scriptArgs].join("\n "); + + await mkdir(testDir, { recursive: true }); + await Promise.all([ + ...filesToCopy.map(async ([src, dst]) => { + const dstDir = path.dirname(dst); + await mkdir(dstDir, { recursive: true }); + await copyFile(src, dst); + }), + ...filesToTransform.map(async ([src, dst, uncomment]) => { + const dstDir = path.dirname(dst); + const content = await readFile(src, { encoding: "utf-8" }); + await mkdir(dstDir, { recursive: true }); + const uncommentedSample = content.replaceAll(uncomment, "$1"); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + writeFile(dst, uncommentedSample, { encoding: "utf-8" }); + }), + writeFile(cmdPath, cmdContent, "utf-8"), + ]); + + const testProcess = fork(scriptPath, scriptArgs, { + env: { + ...process.env, + ...this.config.env, + ALLURE_MOCHA_TESTHOST_PID: process.pid.toString(), + }, + cwd: testDir, + stdio: "pipe", + }); + + const messageReader = new MessageReader(); + + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + testProcess.on("message", messageReader.handleMessage); + + const stdoutPath = path.join(testDir, "stdout.log"); + const stderrPath = path.join(testDir, "stderr.log"); + testProcess.stdout?.setEncoding("utf8").on("data", (chunk: Buffer | string) => { + appendFileSync(stdoutPath, chunk.toString()); + }); + testProcess.stderr?.setEncoding("utf8").on("data", (chunk: Buffer | string) => { + appendFileSync(stderrPath, chunk.toString()); + }); + + return await new Promise((resolve, reject) => { + testProcess.on("exit", (code, signal) => { + if ((code ?? -1) >= 0 && !signal) { + resolve(messageReader.results); + } else if (signal) { + reject(new Error(`mocha was interrupted with ${signal}`)); + } else { + reject(new Error(`mocha failed with exit code ${code || 1}`)); + } + }); + }); + }; + + protected getCopyEntry = (name: string, testDir: string): [string, string] => [ + path.join(this.fixturesPath, name), + path.join(testDir, name), + ]; + + protected getTransformEntry = ( + name: string, + format: ModuleFormat, + testDir: string, + srcDir: string = this.fixturesPath, + ): [string, string, RegExp] => { + return [ + path.join(srcDir, `${name}.js`), + path.join(testDir, `${name}${getFormatExt(format)}`), + uncommentPattern.get(format)!, + ]; + }; + + private getSampleEntry = (name: string | readonly string[], samplesDir: string, testDir: string) => { + if (name instanceof Array) { + name = path.join(...name); + } + return this.getTransformEntry(`${name}.spec`, SPEC_FORMAT, testDir, samplesDir); + }; + + getFilesToCopy: (testDir: string) => readonly [string, string][] = () => []; + getFilesToTransform: (testDir: string) => readonly [string, string, RegExp][] = () => []; + abstract getScriptPath: (testDir: string) => string; + abstract getScriptArgs: () => string[]; +} + +class AllureMochaCliTestRunner extends AllureMochaTestRunner { + getFilesToCopy = (testDir: string) => [this.getCopyEntry("reporter.cjs", testDir)]; + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + getScriptPath = () => path.resolve(require.resolve("mocha"), "../bin/mocha.js"); + getScriptArgs = () => ["--no-color", "--reporter", "./reporter.cjs", "**/*.spec.*"]; +} + +class AllureMochaCodeTestRunner extends AllureMochaTestRunner { + constructor( + config: MochaRunOptions, + private readonly runnerFormat: ModuleFormat, + ) { + super(config); + } + getFilesToTransform = (testDir: string) => [this.getTransformEntry("runner", this.runnerFormat, testDir)]; + getScriptPath = (testDir: string) => path.join(testDir, `runner${getFormatExt(this.runnerFormat)}`); + getScriptArgs = () => ["--"]; +} export const runMochaInlineTest = async ( sampleOrConfig: string | string[] | MochaRunOptions, ...samples: (string | string[])[] -): Promise => { +) => { let options: MochaRunOptions; if (typeof sampleOrConfig === "object" && !(sampleOrConfig instanceof Array)) { options = sampleOrConfig; @@ -23,89 +178,7 @@ export const runMochaInlineTest = async ( options = {}; } - options.mode ??= process.env.ALLURE_MOCHA_TEST_PARALLEL ? "parallel" : "serial"; - - const fixturesPath = path.join(__dirname, "fixtures"); - const samplesPath = path.join(fixturesPath, "samples"); - const runResultsDir = path.join(fixturesPath, "run-results"); - const testDir = path.join(runResultsDir, randomUUID()); - - const reporterFileName = "reporter.cjs"; - const reporterSrcPath = path.join(fixturesPath, reporterFileName); - const reporterDstPath = path.join(testDir, reporterFileName); - - const filesToCopy: [string, string][] = [[reporterSrcPath, reporterDstPath]]; - - const mochaPackagePath = require.resolve("mocha"); - const mochaRunScriptPath = path.resolve(mochaPackagePath, "../bin/mocha.js"); - const mochaArgs = ["--no-color", "--reporter", "./reporter.cjs", "**/*.spec.mjs"]; - - if (options.mode === "parallel") { - const parallelSetupFileName = "setupParallel.cjs"; - const parallelSetupSrcPath = path.join(fixturesPath, parallelSetupFileName); - const parallelSetupDstPath = path.join(testDir, parallelSetupFileName); - - const parallelWriterFileName = "AllureMochaParallelWriter.cjs"; - const parallelWriterSrcPath = path.join(fixturesPath, parallelWriterFileName); - const parallelWriterDstPath = path.join(testDir, parallelWriterFileName); - - filesToCopy.push([parallelSetupSrcPath, parallelSetupDstPath], [parallelWriterSrcPath, parallelWriterDstPath]); - mochaArgs.splice(1, 0, "--parallel", "--require", parallelSetupDstPath); - } - - const cmdPath = path.join(testDir, "cmd.log"); - const cmdContent = [mochaRunScriptPath, ...mochaArgs].map((t) => `"${t}"`).join(" "); - const stdoutPath = path.join(testDir, "stdout.log"); - const stderrPath = path.join(testDir, "stderr.log"); - - await mkdir(testDir, { recursive: true }); - await Promise.all([ - ...filesToCopy.map(([src, dst]) => cp(src, dst)), - writeFile(cmdPath, cmdContent, "utf-8"), - ...samples.map(async (sample) => { - if (sample instanceof Array) { - sample = path.join(...sample); - } - const filename = `${sample}.spec.mjs`; - const source = path.join(samplesPath, filename); - const destination = path.join(testDir, filename); - const destDir = path.dirname(destination); - await mkdir(destDir, { recursive: true }); - await copyFile(source, destination); - }), - ]); - - const testProcess = fork(mochaRunScriptPath, mochaArgs, { - env: { - ...process.env, - ...options.env, - ALLURE_MOCHA_TESTHOST_PID: process.pid.toString(), - }, - cwd: testDir, - stdio: "pipe", - }); - - const messageReader = new MessageReader(); - - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - testProcess.on("message", messageReader.handleMessage); - - testProcess.stdout?.setEncoding("utf8").on("data", (chunk: Buffer | string) => { - appendFileSync(stdoutPath, chunk.toString()); - }); - testProcess.stderr?.setEncoding("utf8").on("data", (chunk: Buffer | string) => { - appendFileSync(stderrPath, chunk.toString()); - }); - - return new Promise((resolve, reject) => { - testProcess.on("exit", (code, signal) => { - if ((code ?? -1) >= 0 && !signal) { - resolve(messageReader.results); - } else if (signal) { - reject(new Error(`mocha was interrupted with ${signal}`)); - } else { - reject(new Error(`mocha failed with exit code ${code || 1}`)); - } - }); - }); + const runner = + RUNNER === "cli" ? new AllureMochaCliTestRunner(options) : new AllureMochaCodeTestRunner(options, RUNNER); + return await runner.run(...samples); }; diff --git a/yarn.lock b/yarn.lock index e7c32dadb..bf52c3d69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -76,6 +76,16 @@ __metadata: languageName: node linkType: hard +"@babel/code-frame@npm:^7.24.7": + version: 7.24.7 + resolution: "@babel/code-frame@npm:7.24.7" + dependencies: + "@babel/highlight": "npm:^7.24.7" + picocolors: "npm:^1.0.0" + checksum: 10/4812e94885ba7e3213d49583a155fdffb05292330f0a9b2c41b49288da70cf3c746a3fda0bf1074041a6d741c33f8d7be24be5e96f41ef77395eeddc5c9ff624 + languageName: node + linkType: hard + "@babel/compat-data@npm:^7.22.6, @babel/compat-data@npm:^7.24.6": version: 7.24.6 resolution: "@babel/compat-data@npm:7.24.6" @@ -479,6 +489,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-string-parser@npm:^7.24.7": + version: 7.24.7 + resolution: "@babel/helper-string-parser@npm:7.24.7" + checksum: 10/603d8d962bbe89907aa99a8f19a006759ab7b2464615f20a6a22e3e2e8375af37ddd0e5175c9e622e1c4b2d83607ffb41055a59d0ce34404502af30fde573a5c + languageName: node + linkType: hard + "@babel/helper-validator-identifier@npm:^7.16.7, @babel/helper-validator-identifier@npm:^7.22.20": version: 7.22.20 resolution: "@babel/helper-validator-identifier@npm:7.22.20" @@ -493,6 +510,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-validator-identifier@npm:^7.24.7": + version: 7.24.7 + resolution: "@babel/helper-validator-identifier@npm:7.24.7" + checksum: 10/86875063f57361471b531dbc2ea10bbf5406e12b06d249b03827d361db4cad2388c6f00936bcd9dc86479f7e2c69ea21412c2228d4b3672588b754b70a449d4b + languageName: node + linkType: hard + "@babel/helper-validator-option@npm:^7.23.5": version: 7.23.5 resolution: "@babel/helper-validator-option@npm:7.23.5" @@ -562,6 +586,18 @@ __metadata: languageName: node linkType: hard +"@babel/highlight@npm:^7.24.7": + version: 7.24.7 + resolution: "@babel/highlight@npm:7.24.7" + dependencies: + "@babel/helper-validator-identifier": "npm:^7.24.7" + chalk: "npm:^2.4.2" + js-tokens: "npm:^4.0.0" + picocolors: "npm:^1.0.0" + checksum: 10/69b73f38cdd4f881b09b939a711e76646da34f4834f4ce141d7a49a6bb1926eab1c594148970a8aa9360398dff800f63aade4e81fafdd7c8d8a8489ea93bfec1 + languageName: node + linkType: hard + "@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.20.5, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.23.0, @babel/parser@npm:^7.23.9, @babel/parser@npm:^7.8.3": version: 7.23.9 resolution: "@babel/parser@npm:7.23.9" @@ -580,6 +616,15 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.24.7": + version: 7.24.7 + resolution: "@babel/parser@npm:7.24.7" + bin: + parser: ./bin/babel-parser.js + checksum: 10/ef9ebce60e13db560ccc7af9235d460f6726bb7e23ae2d675098c1fc43d5249067be60d4118889dad33b1d4f85162cf66baf554719e1669f29bb20e71322568e + languageName: node + linkType: hard + "@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:^7.24.6": version: 7.24.6 resolution: "@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:7.24.6" @@ -1641,6 +1686,17 @@ __metadata: languageName: node linkType: hard +"@babel/template@npm:^7.4.4": + version: 7.24.7 + resolution: "@babel/template@npm:7.24.7" + dependencies: + "@babel/code-frame": "npm:^7.24.7" + "@babel/parser": "npm:^7.24.7" + "@babel/types": "npm:^7.24.7" + checksum: 10/5975d404ef51cf379515eb0f80b115981d0b9dff5539e53a47516644abb8c83d7559f5b083eb1d4977b20d8359ebb2f911ccd4f729143f8958fdc465f976d843 + languageName: node + linkType: hard + "@babel/traverse@npm:7.23.2": version: 7.23.2 resolution: "@babel/traverse@npm:7.23.2" @@ -1727,6 +1783,17 @@ __metadata: languageName: node linkType: hard +"@babel/types@npm:^7.24.7": + version: 7.24.7 + resolution: "@babel/types@npm:7.24.7" + dependencies: + "@babel/helper-string-parser": "npm:^7.24.7" + "@babel/helper-validator-identifier": "npm:^7.24.7" + to-fast-properties: "npm:^2.0.0" + checksum: 10/ad3c8c0d6fb4acb0bb74bb5b4bb849b181bf6185677ef9c59c18856c81e43628d0858253cf232f0eca806f02e08eff85a1d3e636a3e94daea737597796b0b430 + languageName: node + linkType: hard + "@bcoe/v8-coverage@npm:^0.2.3": version: 0.2.3 resolution: "@bcoe/v8-coverage@npm:0.2.3" @@ -4419,6 +4486,7 @@ __metadata: "@typescript-eslint/parser": "npm:^7.0.0" allure-js-commons: "workspace:*" babel-plugin-add-module-exports: "npm:^1.0.4" + babel-plugin-transform-import-meta: "npm:^2.2.1" chai: "npm:^4.3.8" chai-like: "npm:^1.1.1" chai-things: "npm:^0.2.0" @@ -4429,6 +4497,7 @@ __metadata: eslint-plugin-n: "npm:^17.0.0" eslint-plugin-no-null: "npm:^1.0.2" eslint-plugin-prefer-arrow: "npm:^1.2.3" + glob: "npm:^10.4.1" mocha: "npm:^10.2.0" npm-run-all2: "npm:^6.1.2" rimraf: "npm:^5.0.1" @@ -4981,6 +5050,18 @@ __metadata: languageName: node linkType: hard +"babel-plugin-transform-import-meta@npm:^2.2.1": + version: 2.2.1 + resolution: "babel-plugin-transform-import-meta@npm:2.2.1" + dependencies: + "@babel/template": "npm:^7.4.4" + tslib: "npm:^2.4.0" + peerDependencies: + "@babel/core": ^7.10.0 + checksum: 10/d6db38b379e3e42ac9b42c412bb1106b6899663385e0991530168e12c7516c701f70a1f96fdcc29581891d2eebf6f744a71b6fcf1cb2ec78782e0ceabec3d75b + languageName: node + linkType: hard + "babel-preset-current-node-syntax@npm:^1.0.0": version: 1.0.1 resolution: "babel-preset-current-node-syntax@npm:1.0.1" @@ -8356,6 +8437,21 @@ __metadata: languageName: node linkType: hard +"glob@npm:^10.4.1": + version: 10.4.1 + resolution: "glob@npm:10.4.1" + dependencies: + foreground-child: "npm:^3.1.0" + jackspeak: "npm:^3.1.2" + minimatch: "npm:^9.0.4" + minipass: "npm:^7.1.2" + path-scurry: "npm:^1.11.1" + bin: + glob: dist/esm/bin.mjs + checksum: 10/d7bb49d2b413f77bdd59fea4ca86dcc12450deee221af0ca93e09534b81b9ef68fe341345751d8ff0c5b54bad422307e0e44266ff8ad7fbbd0c200e8ec258b16 + languageName: node + linkType: hard + "glob@npm:^6.0.1": version: 6.0.4 resolution: "glob@npm:6.0.4" @@ -9394,6 +9490,19 @@ __metadata: languageName: node linkType: hard +"jackspeak@npm:^3.1.2": + version: 3.4.0 + resolution: "jackspeak@npm:3.4.0" + dependencies: + "@isaacs/cliui": "npm:^8.0.2" + "@pkgjs/parseargs": "npm:^0.11.0" + dependenciesMeta: + "@pkgjs/parseargs": + optional: true + checksum: 10/5032c43c0c1fb92e72846ce496df559214253bc6870c90399cbd7858571c53169d9494b7c152df04abcb75f2fb5e9cffe65651c67d573380adf3a482b150d84b + languageName: node + linkType: hard + "jasmine-core@npm:~3.99.0": version: 3.99.1 resolution: "jasmine-core@npm:3.99.1" @@ -10534,6 +10643,13 @@ __metadata: languageName: node linkType: hard +"lru-cache@npm:^10.2.0": + version: 10.2.2 + resolution: "lru-cache@npm:10.2.2" + checksum: 10/ff1a496d30b5eaec2c9079080965bb0cede203cf878371f7033a007f1e54cd4aa13cc8abf7ccec4c994a83a22ed5476e83a55bb57cc07e6c1547a42937e42c37 + languageName: node + linkType: hard + "lru-cache@npm:^4.0.1": version: 4.1.5 resolution: "lru-cache@npm:4.1.5" @@ -10892,6 +11008,13 @@ __metadata: languageName: node linkType: hard +"minipass@npm:^7.1.2": + version: 7.1.2 + resolution: "minipass@npm:7.1.2" + checksum: 10/c25f0ee8196d8e6036661104bacd743785b2599a21de5c516b32b3fa2b83113ac89a2358465bc04956baab37ffb956ae43be679b2262bf7be15fce467ccd7950 + languageName: node + linkType: hard + "minizlib@npm:^2.1.1, minizlib@npm:^2.1.2": version: 2.1.2 resolution: "minizlib@npm:2.1.2" @@ -11944,6 +12067,16 @@ __metadata: languageName: node linkType: hard +"path-scurry@npm:^1.11.1": + version: 1.11.1 + resolution: "path-scurry@npm:1.11.1" + dependencies: + lru-cache: "npm:^10.2.0" + minipass: "npm:^5.0.0 || ^6.0.2 || ^7.0.0" + checksum: 10/5e8845c159261adda6f09814d7725683257fcc85a18f329880ab4d7cc1d12830967eae5d5894e453f341710d5484b8fdbbd4d75181b4d6e1eb2f4dc7aeadc434 + languageName: node + linkType: hard + "path-to-regexp@npm:^6.2.0, path-to-regexp@npm:^6.2.1": version: 6.2.1 resolution: "path-to-regexp@npm:6.2.1" @@ -14349,6 +14482,13 @@ __metadata: languageName: node linkType: hard +"tslib@npm:^2.4.0": + version: 2.6.3 + resolution: "tslib@npm:2.6.3" + checksum: 10/52109bb681f8133a2e58142f11a50e05476de4f075ca906d13b596ae5f7f12d30c482feb0bff167ae01cfc84c5803e575a307d47938999246f5a49d174fc558c + languageName: node + linkType: hard + "tunnel-agent@npm:^0.6.0": version: 0.6.0 resolution: "tunnel-agent@npm:0.6.0"