@cucumber/cucumber 11.0.0 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/configuration/argv_parser.js +2 -2
- package/lib/configuration/argv_parser.js.map +1 -1
- package/lib/formatter/builtin/html.d.ts +0 -1
- package/lib/formatter/builtin/html.js +0 -1
- package/lib/formatter/builtin/html.js.map +1 -1
- package/lib/formatter/builtin/index.d.ts +15 -2
- package/lib/formatter/builtin/index.js +17 -2
- package/lib/formatter/builtin/index.js.map +1 -1
- package/lib/formatter/builtin/message.d.ts +0 -1
- package/lib/formatter/builtin/message.js +0 -1
- package/lib/formatter/builtin/message.js.map +1 -1
- package/lib/formatter/helpers/formatters.js +0 -2
- package/lib/formatter/helpers/formatters.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.js +1 -0
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/resolve_implementation.js +13 -9
- package/lib/formatter/resolve_implementation.js.map +1 -1
- package/lib/plugin/types.d.ts +0 -1
- package/lib/plugin/types.js.map +1 -1
- package/lib/publish/publish_plugin.js +2 -2
- package/lib/publish/publish_plugin.js.map +1 -1
- package/lib/try_require.js +4 -0
- package/lib/try_require.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/lib/wrapper.mjs +1 -0
- package/package.json +7 -8
- package/lib/formatter/junit_formatter.d.ts +0 -17
- package/lib/formatter/junit_formatter.js +0 -180
- package/lib/formatter/junit_formatter.js.map +0 -1
|
@@ -7,7 +7,7 @@ const commander_1 = require("commander");
|
|
|
7
7
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
8
8
|
const gherkin_1 = require("@cucumber/gherkin");
|
|
9
9
|
const version_1 = require("../version");
|
|
10
|
-
const builtin_1 =
|
|
10
|
+
const builtin_1 = require("../formatter/builtin");
|
|
11
11
|
const ArgvParser = {
|
|
12
12
|
collect(val, memo = []) {
|
|
13
13
|
if (val) {
|
|
@@ -59,7 +59,7 @@ const ArgvParser = {
|
|
|
59
59
|
.option('--exit, --force-exit', 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit')
|
|
60
60
|
.option('--fail-fast', 'abort the run on first failure')
|
|
61
61
|
.option('-f, --format <TYPE[:PATH]>', 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\n' +
|
|
62
|
-
Object.entries(builtin_1.
|
|
62
|
+
Object.entries(builtin_1.documentation).reduce((previous, [key, description]) => previous + ` ${key}: ${description}\n`, ''), ArgvParser.collect)
|
|
63
63
|
.option('--format-options <JSON>', 'provide options for formatters (repeatable)', ArgvParser.mergeJson('--format-options'))
|
|
64
64
|
.option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage)
|
|
65
65
|
.option('--i18n-languages', 'list languages')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC,+CAA4C;AAC5C,wCAAoC;AACpC,mEAA0C;AAkB1C,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAC/B,IAAI,GAAG,EAAE;YACP,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;SACtB;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC7C,IAAI,GAAW,CAAA;YACf,IAAI;gBACF,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACtB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,GAAU,KAAK,CAAA;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yBAAyB,CAAC,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC,C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B,sDAAsD,EACtD,UAAU,CAAC,OAAO,CACnB;aACA,MAAM,CACL,gCAAgC,EAChC,0DAA0D,EAC1D,UAAU,CAAC,OAAO,CACnB;aACA,MAAM,CACL,6BAA6B,EAC7B,sEAAsE,EACtE,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC,CACxD;aACA,MAAM,CACL,iCAAiC,EACjC;wDACgD,EAChD,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CAAC,UAAU,EAAE,iCAAiC,CAAC;aACrD,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;aAChE,MAAM,CACL,yBAAyB,EACzB,uFAAuF,EACvF,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CACL,2BAA2B,EAC3B,8EAA8E,EAC9E,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC3C,CAAA;QAEH,OAAO,CAAC,WAAW,CACjB,UAAU,EACV,6FAA6F,CAC9F,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;SACnC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport { dialects } from '@cucumber/gherkin'\nimport { version } from '../version'\nimport builtin from '../formatter/builtin'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command('cucumber-js')\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Object.entries(builtin).reduce(\n (previous, [key, formatter]) =>\n previous + ` ${key}: ${formatter.documentation}\\n`,\n ''\n ),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '-l, --loader <NODE_MODULE>',\n 'module specifier(s) for loaders to be registered ahead of loading support code',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\"\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
1
|
+
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC,+CAA4C;AAC5C,wCAAoC;AACpC,kDAAoD;AAkBpD,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAC/B,IAAI,GAAG,EAAE;YACP,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;SACtB;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC7C,IAAI,GAAW,CAAA;YACf,IAAI;gBACF,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACtB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,GAAU,KAAK,CAAA;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yBAAyB,CAAC,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC,CAAA;aACvE;YACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACjD,MAAM,IAAI,K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BAA6B,EAC7B,sEAAsE,EACtE,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC,CACxD;aACA,MAAM,CACL,iCAAiC,EACjC;wDACgD,EAChD,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CAAC,UAAU,EAAE,iCAAiC,CAAC;aACrD,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;aAChE,MAAM,CACL,yBAAyB,EACzB,uFAAuF,EACvF,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CACL,2BAA2B,EAC3B,8EAA8E,EAC9E,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC3C,CAAA;QAEH,OAAO,CAAC,WAAW,CACjB,UAAU,EACV,6FAA6F,CAC9F,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;SACnC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport { dialects } from '@cucumber/gherkin'\nimport { version } from '../version'\nimport { documentation } from '../formatter/builtin'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command('cucumber-js')\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Object.entries(documentation).reduce(\n (previous, [key, description]) =>\n previous + ` ${key}: ${description}\\n`,\n ''\n ),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '-l, --loader <NODE_MODULE>',\n 'module specifier(s) for loaders to be registered ahead of loading support code',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\"\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
@@ -4,7 +4,6 @@ interface Options {
|
|
|
4
4
|
declare const _default: {
|
|
5
5
|
type: "formatter";
|
|
6
6
|
formatter({ on, options, write, directory }: import("../../plugin").FormatterPluginContext<Options>): () => Promise<void>;
|
|
7
|
-
documentation: string;
|
|
8
7
|
optionsKey: string;
|
|
9
8
|
};
|
|
10
9
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../../src/formatter/builtin/html.ts"],"names":[],"mappings":";;;;;AAAA,yCAAqC;AACrC,6CAAsC;AACtC,qCAAmC;AACnC,0DAA4B;AAC5B,6DAA6D;AAC7D,8DAAoC;AACpC,gDAA4B;AAC5B,iDAK2B;AAO3B,kBAAe;IACb,IAAI,EAAE,WAAW;IACjB,SAAS,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE;QACzC,IAAI,CAAC,SAAS,IAAI,OAAO,CAAC,mBAAmB,EAAE;YAC7C,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAA;SACF;QACD,MAAM,KAAK,GAAG,sBAAW,CAAC,IAAI,EAAE,CAAA;QAChC,MAAM,UAAU,GAAG,IAAI,mCAAkB,CACvC,IAAA,qBAAU,EAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,gBAAgB,EAClB,IAAA,qBAAU,EAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE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AAM;CACgB,CAAA;AAEpC,MAAM,kBAAkB,GAAG,CAAC,2BAA2B,EAAE,eAAe,CAAC,CAAA;AAEzE,MAAM,YAAY,GAAG;IACnB,QAAQ,EAAE,OAAO;IACjB,MAAM,EAAE,QAAQ;CACR,CAAA;AAEV,SAAS,qBAAqB,CAC5B,KAAmB,EACnB,QAAoB,EACpB,SAAiB;IAEjB,IAAI,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACnD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAA;KAChC;IACD,IAAI,QAAQ,GAAG,cAAc,KAAK,EAAE,EAAE,CAAA;IACtC,MAAM,SAAS,GAAG,cAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IAC5D,IAAI,SAAS,EAAE;QACb,QAAQ,IAAI,IAAI,SAAS,EAAE,CAAA;KAC5B;IACD,MAAM,cAAc,GAAG,IAAA,qBAAS,EAAC,mBAAS,CAAC,CACzC,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAC9B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CACnE,CAAA;IACD,MAAM,OAAO,GAAe;QAC1B,GAAG,QAAQ;QACX,eAAe,EAAE,oCAAyB,CAAC,QAAQ;QACnD,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,KAAK,QAAQ,EAAE;KACrB,CAAA;IACD,OAAO;QACL,UAAU,EAAE,OAAO;QACnB,cAAc;KACf,CAAA;AACH,CAAC","sourcesContent":["import { promisify } from 'node:util'\nimport { finished } from 'node:stream'\nimport { writeFile } from 'node:fs'\nimport path from 'node:path'\nimport { CucumberHtmlStream } from '@cucumber/html-formatter'\nimport resolvePkg from 'resolve-pkg'\nimport mimeTypes from 'mime'\nimport {\n Attachment,\n AttachmentContentEncoding,\n Envelope,\n IdGenerator,\n} from '@cucumber/messages'\nimport { FormatterPlugin } from '../../plugin'\n\ninterface Options {\n externalAttachments?: true\n}\n\nexport default {\n type: 'formatter',\n formatter({ on, options, write, directory }) {\n if (!directory && options.externalAttachments) {\n throw new Error(\n 'Unable to externalise attachments when formatter is not writing to a file'\n )\n }\n const newId = IdGenerator.uuid()\n const htmlStream = new CucumberHtmlStream(\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.css',\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.js'\n )\n const writeOperations: Promise<void>[] = []\n on('message', (message) => {\n if (message.attachment && options.externalAttachments) {\n const { attachment, writeOperation } = externaliseAttachment(\n newId,\n message.attachment,\n directory\n )\n htmlStream.write({\n ...message,\n attachment,\n } satisfies Envelope)\n if (writeOperation) {\n writeOperations.push(writeOperation)\n }\n } else {\n htmlStream.write(message)\n }\n })\n htmlStream.on('data', (chunk) => write(chunk))\n\n return async () => {\n htmlStream.end()\n await promisify(finished)(htmlStream)\n await Promise.all(writeOperations)\n }\n },\n optionsKey: 'html',\n} satisfies FormatterPlugin<Options>\n\nconst alwaysInlinedTypes = ['text/x.cucumber.log+plain', 'text/uri-list']\n\nconst encodingsMap = {\n IDENTITY: 'utf-8',\n BASE64: 'base64',\n} as const\n\nfunction externaliseAttachment(\n newId: () => string,\n original: Attachment,\n directory: string\n) {\n if (alwaysInlinedTypes.includes(original.mediaType)) {\n return { attachment: original }\n }\n let filename = `attachment-${newId()}`\n const extension = mimeTypes.getExtension(original.mediaType)\n if (extension) {\n filename += `.${extension}`\n }\n const writeOperation = promisify(writeFile)(\n path.join(directory, filename),\n Buffer.from(original.body, encodingsMap[original.contentEncoding])\n )\n const updated: Attachment = {\n ...original,\n contentEncoding: AttachmentContentEncoding.IDENTITY,\n body: '',\n url: `./${filename}`,\n }\n return {\n attachment: updated,\n writeOperation,\n }\n}\n"]}
|
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
import { FormatterImplementation } from '../index';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const _default: Record<string, string | FormatterImplementation>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare const documentation: {
|
|
5
|
+
html: string;
|
|
6
|
+
junit: string;
|
|
7
|
+
message: string;
|
|
8
|
+
json: string;
|
|
9
|
+
progress: string;
|
|
10
|
+
'progress-bar': string;
|
|
11
|
+
rerun: string;
|
|
12
|
+
snippets: string;
|
|
13
|
+
summary: string;
|
|
14
|
+
usage: string;
|
|
15
|
+
'usage-json': string;
|
|
16
|
+
};
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.documentation = void 0;
|
|
6
7
|
const json_formatter_1 = __importDefault(require("../json_formatter"));
|
|
7
8
|
const progress_formatter_1 = __importDefault(require("../progress_formatter"));
|
|
8
9
|
const progress_bar_formatter_1 = __importDefault(require("../progress_bar_formatter"));
|
|
@@ -11,12 +12,12 @@ const snippets_formatter_1 = __importDefault(require("../snippets_formatter"));
|
|
|
11
12
|
const summary_formatter_1 = __importDefault(require("../summary_formatter"));
|
|
12
13
|
const usage_formatter_1 = __importDefault(require("../usage_formatter"));
|
|
13
14
|
const usage_json_formatter_1 = __importDefault(require("../usage_json_formatter"));
|
|
14
|
-
const junit_formatter_1 = __importDefault(require("../junit_formatter"));
|
|
15
15
|
const message_1 = __importDefault(require("./message"));
|
|
16
16
|
const html_1 = __importDefault(require("./html"));
|
|
17
17
|
const builtin = {
|
|
18
18
|
// new plugin-based formatters
|
|
19
19
|
html: html_1.default,
|
|
20
|
+
junit: '@cucumber/junit-xml-formatter',
|
|
20
21
|
message: message_1.default,
|
|
21
22
|
// legacy class-based formatters
|
|
22
23
|
json: json_formatter_1.default,
|
|
@@ -27,7 +28,21 @@ const builtin = {
|
|
|
27
28
|
summary: summary_formatter_1.default,
|
|
28
29
|
usage: usage_formatter_1.default,
|
|
29
30
|
'usage-json': usage_json_formatter_1.default,
|
|
30
|
-
junit: junit_formatter_1.default,
|
|
31
31
|
};
|
|
32
32
|
exports.default = builtin;
|
|
33
|
+
exports.documentation = {
|
|
34
|
+
// new plugin-based formatters
|
|
35
|
+
html: 'Outputs a HTML report',
|
|
36
|
+
junit: 'Produces a JUnit XML report',
|
|
37
|
+
message: 'Emits Cucumber messages in newline-delimited JSON',
|
|
38
|
+
// legacy class-based formatters
|
|
39
|
+
json: json_formatter_1.default.documentation,
|
|
40
|
+
progress: progress_formatter_1.default.documentation,
|
|
41
|
+
'progress-bar': progress_bar_formatter_1.default.documentation,
|
|
42
|
+
rerun: rerun_formatter_1.default.documentation,
|
|
43
|
+
snippets: snippets_formatter_1.default.documentation,
|
|
44
|
+
summary: summary_formatter_1.default.documentation,
|
|
45
|
+
usage: usage_formatter_1.default.documentation,
|
|
46
|
+
'usage-json': usage_json_formatter_1.default.documentation,
|
|
47
|
+
};
|
|
33
48
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/builtin/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/builtin/index.ts"],"names":[],"mappings":";;;;;;AACA,uEAA6C;AAC7C,+EAAqD;AACrD,uFAA4D;AAC5D,yEAA+C;AAC/C,+EAAqD;AACrD,6EAAmD;AACnD,yEAA+C;AAC/C,mFAAwD;AACxD,wDAAwC;AACxC,kDAAkC;AAElC,MAAM,OAAO,GAAG;IACd,8BAA8B;IAC9B,IAAI,EAAE,cAAa;IACnB,KAAK,EAAE,+BAA+B;IACtC,OAAO,EAAE,iBAAgB;IACzB,gCAAgC;IAChC,IAAI,EAAE,wBAAa;IACnB,QAAQ,EAAE,4BAAiB;IAC3B,cAAc,EAAE,gCAAoB;IACpC,KAAK,EAAE,yBAAc;IACrB,QAAQ,EAAE,4BAAiB;IAC3B,OAAO,EAAE,2BAAgB;IACzB,KAAK,EAAE,yBAAc;IACrB,YAAY,EAAE,8BAAkB;CACmC,CAAA;AAErE,kBAAe,OAA2D,CAAA;AAE7D,QAAA,aAAa,GAAG;IAC3B,8BAA8B;IAC9B,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE,6BAA6B;IACpC,OAAO,EAAE,mDAAmD;IAC5D,gCAAgC;IAChC,IAAI,EAAE,wBAAa,CAAC,aAAa;IACjC,QAAQ,EAAE,4BAAiB,CAAC,aAAa;IACzC,cAAc,EAAE,gCAAoB,CAAC,aAAa;IAClD,KAAK,EAAE,yBAAc,CAAC,aAAa;IACnC,QAAQ,EAAE,4BAAiB,CAAC,aAAa;IACzC,OAAO,EAAE,2BAAgB,CAAC,aAAa;IACvC,KAAK,EAAE,yBAAc,CAAC,aAAa;IACnC,YAAY,EAAE,8BAAkB,CAAC,aAAa;CACA,CAAA","sourcesContent":["import { FormatterImplementation } from '../index'\nimport JsonFormatter from '../json_formatter'\nimport ProgressFormatter from '../progress_formatter'\nimport ProgressBarFormatter from '../progress_bar_formatter'\nimport RerunFormatter from '../rerun_formatter'\nimport SnippetsFormatter from '../snippets_formatter'\nimport SummaryFormatter from '../summary_formatter'\nimport UsageFormatter from '../usage_formatter'\nimport UsageJsonFormatter from '../usage_json_formatter'\nimport messageFormatter from './message'\nimport htmlFormatter from './html'\n\nconst builtin = {\n // new plugin-based formatters\n html: htmlFormatter,\n junit: '@cucumber/junit-xml-formatter',\n message: messageFormatter,\n // legacy class-based formatters\n json: JsonFormatter,\n progress: ProgressFormatter,\n 'progress-bar': ProgressBarFormatter,\n rerun: RerunFormatter,\n snippets: SnippetsFormatter,\n summary: SummaryFormatter,\n usage: UsageFormatter,\n 'usage-json': UsageJsonFormatter,\n} as const satisfies Record<string, FormatterImplementation | string>\n\nexport default builtin as Record<string, FormatterImplementation | string>\n\nexport const documentation = {\n // new plugin-based formatters\n html: 'Outputs a HTML report',\n junit: 'Produces a JUnit XML report',\n message: 'Emits Cucumber messages in newline-delimited JSON',\n // legacy class-based formatters\n json: JsonFormatter.documentation,\n progress: ProgressFormatter.documentation,\n 'progress-bar': ProgressBarFormatter.documentation,\n rerun: RerunFormatter.documentation,\n snippets: SnippetsFormatter.documentation,\n summary: SummaryFormatter.documentation,\n usage: UsageFormatter.documentation,\n 'usage-json': UsageJsonFormatter.documentation,\n} satisfies Record<keyof typeof builtin, string>\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/formatter/builtin/message.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,WAAW;IACjB,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE;QACrB,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACnE,CAAC;
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/formatter/builtin/message.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,WAAW;IACjB,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE;QACrB,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACnE,CAAC;CACwB,CAAA","sourcesContent":["import { FormatterPlugin } from '../../plugin'\n\nexport default {\n type: 'formatter',\n formatter({ on, write }) {\n on('message', (message) => write(JSON.stringify(message) + '\\n'))\n },\n} satisfies FormatterPlugin\n"]}
|
|
@@ -11,7 +11,6 @@ const snippets_formatter_1 = __importDefault(require("../snippets_formatter"));
|
|
|
11
11
|
const summary_formatter_1 = __importDefault(require("../summary_formatter"));
|
|
12
12
|
const usage_formatter_1 = __importDefault(require("../usage_formatter"));
|
|
13
13
|
const usage_json_formatter_1 = __importDefault(require("../usage_json_formatter"));
|
|
14
|
-
const junit_formatter_1 = __importDefault(require("../junit_formatter"));
|
|
15
14
|
const Formatters = {
|
|
16
15
|
getFormatters() {
|
|
17
16
|
return {
|
|
@@ -23,7 +22,6 @@ const Formatters = {
|
|
|
23
22
|
summary: summary_formatter_1.default,
|
|
24
23
|
usage: usage_formatter_1.default,
|
|
25
24
|
'usage-json': usage_json_formatter_1.default,
|
|
26
|
-
junit: junit_formatter_1.default,
|
|
27
25
|
};
|
|
28
26
|
},
|
|
29
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/formatter/helpers/formatters.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,uFAA4D;AAC5D,+EAAqD;AACrD,yEAA+C;AAC/C,+EAAqD;AACrD,6EAAmD;AACnD,yEAA+C;AAC/C,mFAAwD;
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/formatter/helpers/formatters.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,uFAA4D;AAC5D,+EAAqD;AACrD,yEAA+C;AAC/C,+EAAqD;AACrD,6EAAmD;AACnD,yEAA+C;AAC/C,mFAAwD;AAExD,MAAM,UAAU,GAAG;IACjB,aAAa;QACX,OAAO;YACL,IAAI,EAAE,wBAAa;YACnB,QAAQ,EAAE,4BAAiB;YAC3B,cAAc,EAAE,gCAAoB;YACpC,KAAK,EAAE,yBAAc;YACrB,QAAQ,EAAE,4BAAiB;YAC3B,OAAO,EAAE,2BAAgB;YACzB,KAAK,EAAE,yBAAc;YACrB,YAAY,EAAE,8BAAkB;SACjC,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import Formatter from '../.'\nimport JsonFormatter from '../json_formatter'\nimport ProgressBarFormatter from '../progress_bar_formatter'\nimport ProgressFormatter from '../progress_formatter'\nimport RerunFormatter from '../rerun_formatter'\nimport SnippetsFormatter from '../snippets_formatter'\nimport SummaryFormatter from '../summary_formatter'\nimport UsageFormatter from '../usage_formatter'\nimport UsageJsonFormatter from '../usage_json_formatter'\n\nconst Formatters = {\n getFormatters(): Record<string, typeof Formatter> {\n return {\n json: JsonFormatter,\n progress: ProgressFormatter,\n 'progress-bar': ProgressBarFormatter,\n rerun: RerunFormatter,\n snippets: SnippetsFormatter,\n summary: SummaryFormatter,\n usage: UsageFormatter,\n 'usage-json': UsageJsonFormatter,\n }\n },\n}\n\nexport default Formatters\n"]}
|
|
@@ -34,6 +34,7 @@ const STATUS_REPORT_ORDER = [
|
|
|
34
34
|
messages.TestStepResultStatus.PENDING,
|
|
35
35
|
messages.TestStepResultStatus.SKIPPED,
|
|
36
36
|
messages.TestStepResultStatus.PASSED,
|
|
37
|
+
messages.TestStepResultStatus.UNKNOWN,
|
|
37
38
|
];
|
|
38
39
|
function formatSummary({ colorFns, testCaseAttempts, testRunDuration, }) {
|
|
39
40
|
const testCaseResults = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary_helpers.js","sourceRoot":"","sources":["../../../src/formatter/helpers/summary_helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,iCAAgC;AAEhC,uDAAmD;AAGnD,MAAM,mBAAmB,GAAG;IAC1B,QAAQ,CAAC,oBAAoB,CAAC,MAAM;IACpC,QAAQ,CAAC,oBAAoB,CAAC,SAAS;IACvC,QAAQ,CAAC,oBAAoB,CAAC,SAAS;IACvC,QAAQ,CAAC,oBAAoB,CAAC,OAAO;IACrC,QAAQ,CAAC,oBAAoB,CAAC,OAAO;IACrC,QAAQ,CAAC,oBAAoB,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"summary_helpers.js","sourceRoot":"","sources":["../../../src/formatter/helpers/summary_helpers.ts"],"names":[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AAM,OAAO,GAAa,EAAE,CAAA;QAC5B,mBAAmB,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;gBACtB,OAAO,CAAC,IAAI,CACV,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CACxB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CACvD,CACF,CAAA;aACF;QACH,CAAC,CAAC,CAAA;QACF,IAAI,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAA;KACnC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,kBAAkB,CAAC,WAA8B;IACxD,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAA;IACzB,MAAM,GAAG,GAAG,IAAI,IAAI,CAClB,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAC5D,CAAA;IACD,MAAM,QAAQ,GAAG,gBAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC;QAC7D,SAAS;QACT,SAAS;QACT,cAAc;KACf,CAAC,CAAA;IACF,OAAO,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { Interval } from 'luxon'\nimport { IColorFns } from '../get_color_fns'\nimport { doesHaveValue } from '../../value_checker'\nimport { ITestCaseAttempt } from './event_data_collector'\n\nconst STATUS_REPORT_ORDER = [\n messages.TestStepResultStatus.FAILED,\n messages.TestStepResultStatus.AMBIGUOUS,\n messages.TestStepResultStatus.UNDEFINED,\n messages.TestStepResultStatus.PENDING,\n messages.TestStepResultStatus.SKIPPED,\n messages.TestStepResultStatus.PASSED,\n messages.TestStepResultStatus.UNKNOWN,\n]\n\nexport interface IFormatSummaryRequest {\n colorFns: IColorFns\n testCaseAttempts: ITestCaseAttempt[]\n testRunDuration: messages.Duration\n}\n\nexport function formatSummary({\n colorFns,\n testCaseAttempts,\n testRunDuration,\n}: IFormatSummaryRequest): string {\n const testCaseResults: messages.TestStepResult[] = []\n const testStepResults: messages.TestStepResult[] = []\n let totalStepDuration = messages.TimeConversion.millisecondsToDuration(0)\n testCaseAttempts.forEach(\n ({ testCase, willBeRetried, worstTestStepResult, stepResults }) => {\n Object.values(stepResults).forEach((stepResult) => {\n totalStepDuration = messages.TimeConversion.addDurations(\n totalStepDuration,\n stepResult.duration\n )\n })\n if (!willBeRetried) {\n testCaseResults.push(worstTestStepResult)\n testCase.testSteps.forEach((testStep) => {\n if (doesHaveValue(testStep.pickleStepId)) {\n testStepResults.push(stepResults[testStep.id])\n }\n })\n }\n }\n )\n const scenarioSummary = getCountSummary({\n colorFns,\n objects: testCaseResults,\n type: 'scenario',\n })\n const stepSummary = getCountSummary({\n colorFns,\n objects: testStepResults,\n type: 'step',\n })\n const durationSummary = `${getDurationSummary(\n testRunDuration\n )} (executing steps: ${getDurationSummary(totalStepDuration)})\\n`\n return [scenarioSummary, stepSummary, durationSummary].join('\\n')\n}\n\ninterface IGetCountSummaryRequest {\n colorFns: IColorFns\n objects: messages.TestStepResult[]\n type: string\n}\n\nfunction getCountSummary({\n colorFns,\n objects,\n type,\n}: IGetCountSummaryRequest): string {\n const counts: Record<string, number> = {}\n STATUS_REPORT_ORDER.forEach((x) => (counts[x] = 0))\n objects.forEach((x) => (counts[x.status] += 1))\n const total = Object.values(counts).reduce((acc, x) => acc + x, 0)\n let text = `${total.toString()} ${type}${total === 1 ? '' : 's'}`\n if (total > 0) {\n const details: string[] = []\n STATUS_REPORT_ORDER.forEach((status) => {\n if (counts[status] > 0) {\n details.push(\n colorFns.forStatus(status)(\n `${counts[status].toString()} ${status.toLowerCase()}`\n )\n )\n }\n })\n text += ` (${details.join(', ')})`\n }\n return text\n}\n\nfunction getDurationSummary(durationMsg: messages.Duration): string {\n const start = new Date(0)\n const end = new Date(\n messages.TimeConversion.durationToMilliseconds(durationMsg)\n )\n const duration = Interval.fromDateTimes(start, end).toDuration([\n 'minutes',\n 'seconds',\n 'milliseconds',\n ])\n return duration.toFormat(\"m'm'ss.SSS's'\")\n}\n"]}
|
|
@@ -8,17 +8,21 @@ const builtin_1 = __importDefault(require("./builtin"));
|
|
|
8
8
|
const import_code_1 = require("./import_code");
|
|
9
9
|
const find_class_or_plugin_1 = require("./find_class_or_plugin");
|
|
10
10
|
async function resolveImplementation(specifier, cwd) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
throw new Error(`${specifier} does not export a function/class`);
|
|
11
|
+
const fromBuiltin = builtin_1.default[specifier];
|
|
12
|
+
if (fromBuiltin) {
|
|
13
|
+
if (typeof fromBuiltin !== 'string') {
|
|
14
|
+
return fromBuiltin;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
specifier = fromBuiltin;
|
|
19
18
|
}
|
|
20
|
-
return found;
|
|
21
19
|
}
|
|
20
|
+
const imported = await (0, import_code_1.importCode)(specifier, cwd);
|
|
21
|
+
const found = (0, find_class_or_plugin_1.findClassOrPlugin)(imported);
|
|
22
|
+
if (!found) {
|
|
23
|
+
throw new Error(`${specifier} does not export a function/class`);
|
|
24
|
+
}
|
|
25
|
+
return found;
|
|
22
26
|
}
|
|
23
27
|
exports.resolveImplementation = resolveImplementation;
|
|
24
28
|
//# sourceMappingURL=resolve_implementation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve_implementation.js","sourceRoot":"","sources":["../../src/formatter/resolve_implementation.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+B;AAC/B,+CAA0C;AAC1C,iEAA0D;AAGnD,KAAK,UAAU,qBAAqB,CACzC,SAAiB,EACjB,GAAW;IAEX,
|
|
1
|
+
{"version":3,"file":"resolve_implementation.js","sourceRoot":"","sources":["../../src/formatter/resolve_implementation.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+B;AAC/B,+CAA0C;AAC1C,iEAA0D;AAGnD,KAAK,UAAU,qBAAqB,CACzC,SAAiB,EACjB,GAAW;IAEX,MAAM,WAAW,GAAG,iBAAO,CAAC,SAAS,CAAC,CAAA;IACtC,IAAI,WAAW,EAAE;QACf,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;YACnC,OAAO,WAAW,CAAA;SACnB;aAAM;YACL,SAAS,GAAG,WAAW,CAAA;SACxB;KACF;IACD,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAU,EAAC,SAAS,EAAE,GAAG,CAAC,CAAA;IACjD,MAAM,KAAK,GAAG,IAAA,wCAAiB,EAAC,QAAQ,CAAC,CAAA;IACzC,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,mCAAmC,CAAC,CAAA;KACjE;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAlBD,sDAkBC","sourcesContent":["import builtin from './builtin'\nimport { importCode } from './import_code'\nimport { findClassOrPlugin } from './find_class_or_plugin'\nimport { FormatterImplementation } from './index'\n\nexport async function resolveImplementation(\n specifier: string,\n cwd: string\n): Promise<FormatterImplementation> {\n const fromBuiltin = builtin[specifier]\n if (fromBuiltin) {\n if (typeof fromBuiltin !== 'string') {\n return fromBuiltin\n } else {\n specifier = fromBuiltin\n }\n }\n const imported = await importCode(specifier, cwd)\n const found = findClassOrPlugin(imported)\n if (!found) {\n throw new Error(`${specifier} does not export a function/class`)\n }\n return found\n}\n"]}
|
package/lib/plugin/types.d.ts
CHANGED
|
@@ -47,6 +47,5 @@ export type FormatterPluginFunction<OptionsType> = (context: FormatterPluginCont
|
|
|
47
47
|
export interface FormatterPlugin<OptionsType = any> {
|
|
48
48
|
type: 'formatter';
|
|
49
49
|
formatter: FormatterPluginFunction<OptionsType>;
|
|
50
|
-
documentation: string;
|
|
51
50
|
optionsKey?: string;
|
|
52
51
|
}
|
package/lib/plugin/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Envelope } from '@cucumber/messages'\nimport { ArrayValues, Promisable } from 'type-fest'\nimport { IRunEnvironment } from '../api'\nimport { ILogger } from '../logger'\nimport { IFilterablePickle } from '../filter'\nimport { IResolvedPaths } from '../paths'\nimport { coordinatorTransformKeys, coordinatorVoidKeys } from './events'\n\nexport type Operation = 'loadSources' | 'loadSupport' | 'runCucumber'\n\nexport type CoordinatorPluginVoidEventKey = ArrayValues<\n typeof coordinatorVoidKeys\n>\nexport type CoordinatorPluginTransformEventKey = ArrayValues<\n typeof coordinatorTransformKeys\n>\nexport type CoordinatorPluginEventKey =\n | CoordinatorPluginVoidEventKey\n | CoordinatorPluginTransformEventKey\n\nexport type CoordinatorPluginEventValues = {\n // void\n message: Readonly<Envelope>\n 'paths:resolve': Readonly<IResolvedPaths>\n // transform\n 'pickles:filter': Readonly<Array<IFilterablePickle>>\n 'pickles:order': Readonly<Array<IFilterablePickle>>\n}\n\nexport type CoordinatorPluginEventHandler<K extends CoordinatorPluginEventKey> =\n (\n value: CoordinatorPluginEventValues[K]\n ) => K extends CoordinatorPluginTransformEventKey\n ? Promisable<CoordinatorPluginEventValues[K]>\n : void\n\nexport interface CoordinatorPluginContext<OptionsType> {\n operation: Operation\n on: <EventKey extends CoordinatorPluginEventKey>(\n event: EventKey,\n handler: CoordinatorPluginEventHandler<EventKey>\n ) => void\n options: OptionsType\n logger: ILogger\n environment: Required<IRunEnvironment>\n}\n\nexport type CoordinatorPluginFunction<OptionsType> = (\n context: CoordinatorPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport type PluginCleanup = () => Promisable<void>\n\n/**\n * A plugin to implement Cucumber built-in functionality.\n *\n * Uses the same events and mechanisms as user-authored plugins, but is free to require configuration and context from\n * inside of Cucumber as its `options`, whereas user-authored plugins will be limited to `pluginOptions` from the\n * project configuration.\n */\nexport interface InternalPlugin<OptionsType = any> {\n type: 'plugin'\n coordinator: CoordinatorPluginFunction<OptionsType>\n}\n\nexport interface FormatterPluginContext<OptionsType> {\n on: (key: 'message', handler: (value: Envelope) => void) => void\n options: OptionsType\n logger: ILogger\n write: (buffer: string | Uint8Array) => void\n directory?: string\n}\n\nexport type FormatterPluginFunction<OptionsType> = (\n context: FormatterPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport interface FormatterPlugin<OptionsType = any> {\n type: 'formatter'\n formatter: FormatterPluginFunction<OptionsType>\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Envelope } from '@cucumber/messages'\nimport { ArrayValues, Promisable } from 'type-fest'\nimport { IRunEnvironment } from '../api'\nimport { ILogger } from '../logger'\nimport { IFilterablePickle } from '../filter'\nimport { IResolvedPaths } from '../paths'\nimport { coordinatorTransformKeys, coordinatorVoidKeys } from './events'\n\nexport type Operation = 'loadSources' | 'loadSupport' | 'runCucumber'\n\nexport type CoordinatorPluginVoidEventKey = ArrayValues<\n typeof coordinatorVoidKeys\n>\nexport type CoordinatorPluginTransformEventKey = ArrayValues<\n typeof coordinatorTransformKeys\n>\nexport type CoordinatorPluginEventKey =\n | CoordinatorPluginVoidEventKey\n | CoordinatorPluginTransformEventKey\n\nexport type CoordinatorPluginEventValues = {\n // void\n message: Readonly<Envelope>\n 'paths:resolve': Readonly<IResolvedPaths>\n // transform\n 'pickles:filter': Readonly<Array<IFilterablePickle>>\n 'pickles:order': Readonly<Array<IFilterablePickle>>\n}\n\nexport type CoordinatorPluginEventHandler<K extends CoordinatorPluginEventKey> =\n (\n value: CoordinatorPluginEventValues[K]\n ) => K extends CoordinatorPluginTransformEventKey\n ? Promisable<CoordinatorPluginEventValues[K]>\n : void\n\nexport interface CoordinatorPluginContext<OptionsType> {\n operation: Operation\n on: <EventKey extends CoordinatorPluginEventKey>(\n event: EventKey,\n handler: CoordinatorPluginEventHandler<EventKey>\n ) => void\n options: OptionsType\n logger: ILogger\n environment: Required<IRunEnvironment>\n}\n\nexport type CoordinatorPluginFunction<OptionsType> = (\n context: CoordinatorPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport type PluginCleanup = () => Promisable<void>\n\n/**\n * A plugin to implement Cucumber built-in functionality.\n *\n * Uses the same events and mechanisms as user-authored plugins, but is free to require configuration and context from\n * inside of Cucumber as its `options`, whereas user-authored plugins will be limited to `pluginOptions` from the\n * project configuration.\n */\nexport interface InternalPlugin<OptionsType = any> {\n type: 'plugin'\n coordinator: CoordinatorPluginFunction<OptionsType>\n}\n\nexport interface FormatterPluginContext<OptionsType> {\n on: (key: 'message', handler: (value: Envelope) => void) => void\n options: OptionsType\n logger: ILogger\n write: (buffer: string | Uint8Array) => void\n directory?: string\n}\n\nexport type FormatterPluginFunction<OptionsType> = (\n context: FormatterPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport interface FormatterPlugin<OptionsType = any> {\n type: 'formatter'\n formatter: FormatterPluginFunction<OptionsType>\n optionsKey?: string\n}\n"]}
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.publishPlugin = void 0;
|
|
7
7
|
const node_stream_1 = require("node:stream");
|
|
8
|
+
const node_util_1 = require("node:util");
|
|
8
9
|
const supports_color_1 = require("supports-color");
|
|
9
10
|
const has_ansi_1 = __importDefault(require("has-ansi"));
|
|
10
|
-
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
11
11
|
const http_stream_1 = __importDefault(require("./http_stream"));
|
|
12
12
|
const DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports';
|
|
13
13
|
exports.publishPlugin = {
|
|
@@ -46,7 +46,7 @@ compose the console message on this end.
|
|
|
46
46
|
*/
|
|
47
47
|
function sanitisePublishOutput(raw, stderr) {
|
|
48
48
|
if (!(0, supports_color_1.supportsColor)(stderr) && (0, has_ansi_1.default)(raw)) {
|
|
49
|
-
return (0,
|
|
49
|
+
return (0, node_util_1.stripVTControlCharacters)(raw);
|
|
50
50
|
}
|
|
51
51
|
return raw;
|
|
52
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish_plugin.js","sourceRoot":"","sources":["../../src/publish/publish_plugin.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAsC;AACtC,mDAA8C;AAC9C,wDAA8B;
|
|
1
|
+
{"version":3,"file":"publish_plugin.js","sourceRoot":"","sources":["../../src/publish/publish_plugin.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAsC;AACtC,yCAAoD;AACpD,mDAA8C;AAC9C,wDAA8B;AAG9B,gEAAsC;AAEtC,MAAM,4BAA4B,GAAG,0CAA0C,CAAA;AAElE,QAAA,aAAa,GAA2C;IACnE,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE;QAC1D,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,SAAS,CAAA;SACjB;QACD,MAAM,EAAE,GAAG,GAAG,4BAA4B,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;QAC7D,MAAM,OAAO,GAA8B,EAAE,CAAA;QAC7C,IAAI,KAAK,KAAK,SAAS,EAAE;YACvB,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAA;SAC1C;QACD,MAAM,MAAM,GAAG,IAAI,qBAAU,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;QAClD,MAAM,YAAY,GAAG,IAAI,sBAAQ,CAAC;YAChC,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,UAAU,YAAoB,EAAE,QAAQ,EAAE,aAAa;gBAC5D,WAAW,CAAC,MAAM,CAAC,KAAK,CACtB,qBAAqB,CAAC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAC/D,CAAA;gBACD,aAAa,EAAE,CAAA;YACjB,CAAC;SACF,CAAC,CAAA;QACF,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACzB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;QACjE,EAAE,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;QACpE,OAAO,GAAG,EAAE,CACV,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAC5B,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAA;YACpC,MAAM,CAAC,GAAG,EAAE,CAAA;QACd,CAAC,CAAC,CAAA;IACN,CAAC;CACF,CAAA;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,GAAW,EAAE,MAAgB;IAC1D,IAAI,CAAC,IAAA,8BAAa,EAAC,MAAM,CAAC,IAAI,IAAA,kBAAO,EAAC,GAAG,CAAC,EAAE;QAC1C,OAAO,IAAA,oCAAwB,EAAC,GAAG,CAAC,CAAA;KACrC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import { Writable } from 'node:stream'\nimport { stripVTControlCharacters } from 'node:util'\nimport { supportsColor } from 'supports-color'\nimport hasAnsi from 'has-ansi'\nimport { InternalPlugin } from '../plugin'\nimport { IPublishConfig } from './types'\nimport HttpStream from './http_stream'\n\nconst DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports'\n\nexport const publishPlugin: InternalPlugin<IPublishConfig | false> = {\n type: 'plugin',\n coordinator: async ({ on, logger, options, environment }) => {\n if (!options) {\n return undefined\n }\n const { url = DEFAULT_CUCUMBER_PUBLISH_URL, token } = options\n const headers: { [key: string]: string } = {}\n if (token !== undefined) {\n headers.Authorization = `Bearer ${token}`\n }\n const stream = new HttpStream(url, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n environment.stderr.write(\n sanitisePublishOutput(responseBody, environment.stderr) + '\\n'\n )\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n stream.on('error', (error: Error) => logger.error(error.message))\n on('message', (value) => stream.write(JSON.stringify(value) + '\\n'))\n return () =>\n new Promise<void>((resolve) => {\n stream.on('finish', () => resolve())\n stream.end()\n })\n },\n}\n\n/*\nThis is because the Cucumber Reports service returns a pre-formatted console message\nincluding ANSI escapes, so if our stderr stream doesn't support those we need to\nstrip them back out. Ideally we should get structured data from the service and\ncompose the console message on this end.\n */\nfunction sanitisePublishOutput(raw: string, stderr: Writable) {\n if (!supportsColor(stderr) && hasAnsi(raw)) {\n return stripVTControlCharacters(raw)\n }\n return raw\n}\n"]}
|
package/lib/try_require.js
CHANGED
|
@@ -14,6 +14,10 @@ function tryRequire(path) {
|
|
|
14
14
|
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
15
15
|
throw Error(`Cucumber expected a CommonJS module at '${path}' but found an ES module.
|
|
16
16
|
Either change the file to CommonJS syntax or use the --import directive instead of --require.`, { cause: error });
|
|
17
|
+
}
|
|
18
|
+
else if (error.code === 'ERR_REQUIRE_ASYNC_MODULE') {
|
|
19
|
+
throw Error(`Cucumber expected a CommonJS module or simple ES module at '${path}' but found an async ES module.
|
|
20
|
+
Either change the file so it can be required or use the --import directive instead of --require.`, { cause: error });
|
|
17
21
|
}
|
|
18
22
|
else {
|
|
19
23
|
throw error;
|
package/lib/try_require.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"try_require.js","sourceRoot":"","sources":["../src/try_require.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAwB,UAAU,CAAC,IAAY;IAC7C,IAAI;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;KACrB;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE;YACpC,MAAM,KAAK,CACT,2CAA2C,IAAI;oGAC6C,EAC5F,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAA;SACF;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC;
|
|
1
|
+
{"version":3,"file":"try_require.js","sourceRoot":"","sources":["../src/try_require.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAwB,UAAU,CAAC,IAAY;IAC7C,IAAI;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAA;KACrB;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE;YACpC,MAAM,KAAK,CACT,2CAA2C,IAAI;oGAC6C,EAC5F,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAA;SACF;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,0BAA0B,EAAE;YACpD,MAAM,KAAK,CACT,+DAA+D,IAAI;uGAC4B,EAC/F,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAA;SACF;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC;AApBD,6BAoBC","sourcesContent":["/**\n * Provides a try guarded require call that will throw a more detailed error when\n * the ERR_REQUIRE_ESM error code is encountered.\n *\n * @param {string} path File path to require from.\n */\nexport default function tryRequire(path: string) {\n try {\n return require(path)\n } catch (error) {\n if (error.code === 'ERR_REQUIRE_ESM') {\n throw Error(\n `Cucumber expected a CommonJS module at '${path}' but found an ES module.\n Either change the file to CommonJS syntax or use the --import directive instead of --require.`,\n { cause: error }\n )\n } else if (error.code === 'ERR_REQUIRE_ASYNC_MODULE') {\n throw Error(\n `Cucumber expected a CommonJS module or simple ES module at '${path}' but found an async ES module.\n Either change the file so it can be required or use the --import directive instead of --require.`,\n { cause: error }\n )\n } else {\n throw error\n }\n }\n}\n"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "11.
|
|
1
|
+
export declare const version = "11.1.0";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '11.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '11.1.0'\n"]}
|
package/lib/wrapper.mjs
CHANGED
|
@@ -31,6 +31,7 @@ export const setDefaultTimeout = cucumber.setDefaultTimeout
|
|
|
31
31
|
export const setDefinitionFunctionWrapper =
|
|
32
32
|
cucumber.setDefinitionFunctionWrapper
|
|
33
33
|
export const setWorldConstructor = cucumber.setWorldConstructor
|
|
34
|
+
export const setParallelCanAssign = cucumber.setParallelCanAssign
|
|
34
35
|
export const Then = cucumber.Then
|
|
35
36
|
export const When = cucumber.When
|
|
36
37
|
export const World = cucumber.World
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"gherkin",
|
|
9
9
|
"tests"
|
|
10
10
|
],
|
|
11
|
-
"version": "11.
|
|
11
|
+
"version": "11.1.0",
|
|
12
12
|
"funding": "https://opencollective.com/cucumber",
|
|
13
13
|
"homepage": "https://github.com/cucumber/cucumber-js",
|
|
14
14
|
"author": "Julien Biezemans <jb@jbpros.com>",
|
|
@@ -127,6 +127,7 @@
|
|
|
127
127
|
"Michael Zedeler <michael@zedeler.dk>",
|
|
128
128
|
"Miika Hänninen <miika.hanninen@gmail.com>",
|
|
129
129
|
"Mona Ghassemi (https://github.com/BlueMona)",
|
|
130
|
+
"Namchee (https://github.com/Namchee)",
|
|
130
131
|
"nebehr <thorgeir@tut.by>",
|
|
131
132
|
"Nico Jansen <jansennico@gmail.com>",
|
|
132
133
|
"Niklas Närhinen <niklas@narhinen.net>",
|
|
@@ -156,6 +157,7 @@
|
|
|
156
157
|
"Simon Lampen <simonlampen@vinsight.net>",
|
|
157
158
|
"Sonny Piers <sonny@fastmail.net>",
|
|
158
159
|
"Stanley Shyiko <stanley.shyiko@gmail.com>",
|
|
160
|
+
"Steve Hynding (https://github.com/hynding)",
|
|
159
161
|
"Steve Tooke <tooky@cucumber.io>",
|
|
160
162
|
"szymonprz <szymonprz@gmail.com>",
|
|
161
163
|
"Ted de Koning",
|
|
@@ -207,10 +209,10 @@
|
|
|
207
209
|
},
|
|
208
210
|
"types": "./lib/index.d.ts",
|
|
209
211
|
"engines": {
|
|
210
|
-
"node": "18 || 20 || >=
|
|
212
|
+
"node": "18 || 20 || 22 || >=23"
|
|
211
213
|
},
|
|
212
214
|
"enginesTested": {
|
|
213
|
-
"node": "18 || 20 || 22"
|
|
215
|
+
"node": "18 || 20 || 22 || 23"
|
|
214
216
|
},
|
|
215
217
|
"dependencies": {
|
|
216
218
|
"@cucumber/ci-environment": "10.0.1",
|
|
@@ -219,6 +221,7 @@
|
|
|
219
221
|
"@cucumber/gherkin-streams": "5.0.1",
|
|
220
222
|
"@cucumber/gherkin-utils": "9.0.0",
|
|
221
223
|
"@cucumber/html-formatter": "21.6.0",
|
|
224
|
+
"@cucumber/junit-xml-formatter": "0.6.0",
|
|
222
225
|
"@cucumber/message-streams": "4.0.1",
|
|
223
226
|
"@cucumber/messages": "24.1.0",
|
|
224
227
|
"@cucumber/tag-expressions": "6.1.0",
|
|
@@ -247,12 +250,10 @@
|
|
|
247
250
|
"resolve-pkg": "^2.0.0",
|
|
248
251
|
"semver": "7.5.3",
|
|
249
252
|
"string-argv": "0.3.1",
|
|
250
|
-
"strip-ansi": "6.0.1",
|
|
251
253
|
"supports-color": "^8.1.1",
|
|
252
254
|
"tmp": "0.2.3",
|
|
253
255
|
"type-fest": "^4.8.3",
|
|
254
256
|
"util-arity": "^1.1.0",
|
|
255
|
-
"xmlbuilder": "^15.1.1",
|
|
256
257
|
"yaml": "^2.2.2",
|
|
257
258
|
"yup": "1.2.0"
|
|
258
259
|
},
|
|
@@ -262,7 +263,6 @@
|
|
|
262
263
|
"@microsoft/api-extractor": "7.39.0",
|
|
263
264
|
"@sinonjs/fake-timers": "10.0.2",
|
|
264
265
|
"@types/chai": "4.3.4",
|
|
265
|
-
"@types/chai-xml": "^0.3.2",
|
|
266
266
|
"@types/debug": "4.1.7",
|
|
267
267
|
"@types/dirty-chai": "2.0.2",
|
|
268
268
|
"@types/express": "4.17.15",
|
|
@@ -286,7 +286,6 @@
|
|
|
286
286
|
"@typescript-eslint/parser": "6.7.4",
|
|
287
287
|
"chai": "4.3.7",
|
|
288
288
|
"chai-exclude": "2.1.0",
|
|
289
|
-
"chai-xml": "^0.4.1",
|
|
290
289
|
"coffeescript": "2.7.0",
|
|
291
290
|
"dependency-lint": "7.1.0",
|
|
292
291
|
"dirty-chai": "2.0.1",
|
|
@@ -296,7 +295,7 @@
|
|
|
296
295
|
"eslint-plugin-node": "11.1.0",
|
|
297
296
|
"eslint-plugin-standard": "5.0.0",
|
|
298
297
|
"eslint-plugin-unicorn": "^48.0.1",
|
|
299
|
-
"express": "4.
|
|
298
|
+
"express": "^4.21.0",
|
|
300
299
|
"fs-extra": "10.1.0",
|
|
301
300
|
"genversion": "3.1.1",
|
|
302
301
|
"mocha": "10.2.0",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Formatter, { IFormatterOptions } from './';
|
|
2
|
-
export default class JunitFormatter extends Formatter {
|
|
3
|
-
private readonly names;
|
|
4
|
-
private readonly suiteName;
|
|
5
|
-
static readonly documentation: string;
|
|
6
|
-
constructor(options: IFormatterOptions);
|
|
7
|
-
private getTestCases;
|
|
8
|
-
private getTestSteps;
|
|
9
|
-
private getTestStep;
|
|
10
|
-
private getTestCaseResult;
|
|
11
|
-
private durationToSeconds;
|
|
12
|
-
private nameOrDefault;
|
|
13
|
-
private getTestCaseName;
|
|
14
|
-
private formatTestSteps;
|
|
15
|
-
private onTestRunFinished;
|
|
16
|
-
private buildXmlReport;
|
|
17
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const xmlbuilder_1 = __importDefault(require("xmlbuilder"));
|
|
7
|
-
const messages_1 = require("@cucumber/messages");
|
|
8
|
-
const value_checker_1 = require("../value_checker");
|
|
9
|
-
const value_checker_2 = require("../value_checker");
|
|
10
|
-
const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
|
|
11
|
-
const pickle_parser_1 = require("./helpers/pickle_parser");
|
|
12
|
-
const _1 = __importDefault(require("./"));
|
|
13
|
-
class JunitFormatter extends _1.default {
|
|
14
|
-
names = {};
|
|
15
|
-
suiteName;
|
|
16
|
-
static documentation = 'Outputs JUnit report';
|
|
17
|
-
constructor(options) {
|
|
18
|
-
super(options);
|
|
19
|
-
this.suiteName = (0, value_checker_2.valueOrDefault)(options.parsedArgvOptions.junit?.suiteName, 'cucumber-js');
|
|
20
|
-
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
21
|
-
if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
|
|
22
|
-
this.onTestRunFinished();
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
getTestCases() {
|
|
27
|
-
return this.eventDataCollector
|
|
28
|
-
.getTestCaseAttempts()
|
|
29
|
-
.filter((attempt) => !attempt.willBeRetried);
|
|
30
|
-
}
|
|
31
|
-
getTestSteps(testCaseAttempt, gherkinStepMap, pickleStepMap) {
|
|
32
|
-
return testCaseAttempt.testCase.testSteps.map((testStep) => {
|
|
33
|
-
const isBeforeHook = !(0, value_checker_1.doesHaveValue)(testStep.pickleStepId);
|
|
34
|
-
return this.getTestStep({
|
|
35
|
-
isBeforeHook,
|
|
36
|
-
gherkinStepMap,
|
|
37
|
-
pickleStepMap,
|
|
38
|
-
testStep,
|
|
39
|
-
testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],
|
|
40
|
-
testStepResult: testCaseAttempt.stepResults[testStep.id],
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
getTestStep({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult, }) {
|
|
45
|
-
const data = {};
|
|
46
|
-
if (testStep.pickleStepId) {
|
|
47
|
-
const pickleStep = pickleStepMap[testStep.pickleStepId];
|
|
48
|
-
data.keyword = (0, pickle_parser_1.getStepKeyword)({ pickleStep, gherkinStepMap });
|
|
49
|
-
data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line;
|
|
50
|
-
data.name = pickleStep.text;
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
data.keyword = isBeforeHook ? 'Before' : 'After';
|
|
54
|
-
data.hidden = true;
|
|
55
|
-
}
|
|
56
|
-
data.result = testStepResult;
|
|
57
|
-
data.time = testStepResult.duration
|
|
58
|
-
? this.durationToSeconds(testStepResult.duration)
|
|
59
|
-
: 0;
|
|
60
|
-
data.attachments = testStepAttachments;
|
|
61
|
-
return data;
|
|
62
|
-
}
|
|
63
|
-
getTestCaseResult(steps) {
|
|
64
|
-
const { status, message, exception } = (0, messages_1.getWorstTestStepResult)(steps.map((step) => step.result));
|
|
65
|
-
return {
|
|
66
|
-
status,
|
|
67
|
-
failure: message || exception
|
|
68
|
-
? {
|
|
69
|
-
type: exception?.type,
|
|
70
|
-
message: exception?.message,
|
|
71
|
-
detail: message,
|
|
72
|
-
}
|
|
73
|
-
: undefined,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
durationToSeconds(duration) {
|
|
77
|
-
const NANOS_IN_SECOND = 1000000000;
|
|
78
|
-
return ((duration.seconds * NANOS_IN_SECOND + duration.nanos) / NANOS_IN_SECOND);
|
|
79
|
-
}
|
|
80
|
-
nameOrDefault(name, fallbackSuffix) {
|
|
81
|
-
if (!name) {
|
|
82
|
-
return `(unnamed ${fallbackSuffix})`;
|
|
83
|
-
}
|
|
84
|
-
return name;
|
|
85
|
-
}
|
|
86
|
-
getTestCaseName(feature, rule, pickle) {
|
|
87
|
-
const featureName = this.nameOrDefault(feature.name, 'feature');
|
|
88
|
-
const pickleName = this.nameOrDefault(pickle.name, 'scenario');
|
|
89
|
-
const testCaseName = rule
|
|
90
|
-
? this.nameOrDefault(rule.name, 'rule') + ': ' + pickleName
|
|
91
|
-
: pickleName;
|
|
92
|
-
if (!this.names[featureName]) {
|
|
93
|
-
this.names[featureName] = [];
|
|
94
|
-
}
|
|
95
|
-
let index = 0;
|
|
96
|
-
while (this.names[featureName].includes(index > 0 ? `${testCaseName} [${index}]` : testCaseName)) {
|
|
97
|
-
index++;
|
|
98
|
-
}
|
|
99
|
-
const name = index > 0 ? `${testCaseName} [${index}]` : testCaseName;
|
|
100
|
-
this.names[featureName].push(name);
|
|
101
|
-
return name;
|
|
102
|
-
}
|
|
103
|
-
formatTestSteps(steps) {
|
|
104
|
-
return steps
|
|
105
|
-
.filter((step) => !step.hidden)
|
|
106
|
-
.map((step) => {
|
|
107
|
-
const statusText = step.result.status.toLowerCase();
|
|
108
|
-
const maxLength = 80 - statusText.length - 3;
|
|
109
|
-
const stepText = `${step.keyword}${step.name}`
|
|
110
|
-
.padEnd(maxLength, '.')
|
|
111
|
-
.substring(0, maxLength);
|
|
112
|
-
return `${stepText}...${statusText}`;
|
|
113
|
-
})
|
|
114
|
-
.join('\n');
|
|
115
|
-
}
|
|
116
|
-
onTestRunFinished() {
|
|
117
|
-
const testCases = this.getTestCases();
|
|
118
|
-
const tests = testCases.map((testCaseAttempt) => {
|
|
119
|
-
const { gherkinDocument, pickle } = testCaseAttempt;
|
|
120
|
-
const { feature } = gherkinDocument;
|
|
121
|
-
const gherkinExampleRuleMap = (0, gherkin_document_parser_1.getGherkinExampleRuleMap)(gherkinDocument);
|
|
122
|
-
const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]];
|
|
123
|
-
const gherkinStepMap = (0, gherkin_document_parser_1.getGherkinStepMap)(gherkinDocument);
|
|
124
|
-
const pickleStepMap = (0, pickle_parser_1.getPickleStepMap)(pickle);
|
|
125
|
-
const steps = this.getTestSteps(testCaseAttempt, gherkinStepMap, pickleStepMap);
|
|
126
|
-
const stepDuration = steps.reduce((total, step) => total + (step.time || 0), 0);
|
|
127
|
-
return {
|
|
128
|
-
classname: this.nameOrDefault(feature.name, 'feature'),
|
|
129
|
-
name: this.getTestCaseName(feature, rule, pickle),
|
|
130
|
-
time: stepDuration,
|
|
131
|
-
result: this.getTestCaseResult(steps),
|
|
132
|
-
systemOutput: this.formatTestSteps(steps),
|
|
133
|
-
steps,
|
|
134
|
-
};
|
|
135
|
-
});
|
|
136
|
-
const passed = tests.filter((item) => item.result.status === messages_1.TestStepResultStatus.PASSED).length;
|
|
137
|
-
const skipped = tests.filter((item) => item.result.status === messages_1.TestStepResultStatus.SKIPPED).length;
|
|
138
|
-
const failures = tests.length - passed - skipped;
|
|
139
|
-
const testSuite = {
|
|
140
|
-
name: this.suiteName,
|
|
141
|
-
tests,
|
|
142
|
-
failures,
|
|
143
|
-
skipped,
|
|
144
|
-
time: tests.reduce((total, test) => total + test.time, 0),
|
|
145
|
-
};
|
|
146
|
-
this.log(this.buildXmlReport(testSuite));
|
|
147
|
-
}
|
|
148
|
-
buildXmlReport(testSuite) {
|
|
149
|
-
const xmlReport = xmlbuilder_1.default
|
|
150
|
-
.create('testsuite', { invalidCharReplacement: '' })
|
|
151
|
-
.att('failures', testSuite.failures)
|
|
152
|
-
.att('skipped', testSuite.skipped)
|
|
153
|
-
.att('name', testSuite.name)
|
|
154
|
-
.att('time', testSuite.time)
|
|
155
|
-
.att('tests', testSuite.tests.length);
|
|
156
|
-
testSuite.tests.forEach((test) => {
|
|
157
|
-
const xmlTestCase = xmlReport.ele('testcase', {
|
|
158
|
-
classname: test.classname,
|
|
159
|
-
name: test.name,
|
|
160
|
-
time: test.time,
|
|
161
|
-
});
|
|
162
|
-
if (test.result.status === messages_1.TestStepResultStatus.SKIPPED) {
|
|
163
|
-
xmlTestCase.ele('skipped');
|
|
164
|
-
}
|
|
165
|
-
else if (test.result.status !== messages_1.TestStepResultStatus.PASSED) {
|
|
166
|
-
const xmlFailure = xmlTestCase.ele('failure', {
|
|
167
|
-
type: test.result.failure?.type,
|
|
168
|
-
message: test.result.failure?.message,
|
|
169
|
-
});
|
|
170
|
-
if (test.result?.failure) {
|
|
171
|
-
xmlFailure.cdata(test.result.failure.detail);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
xmlTestCase.ele('system-out', {}).cdata(test.systemOutput);
|
|
175
|
-
});
|
|
176
|
-
return xmlReport.end({ pretty: true });
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
exports.default = JunitFormatter;
|
|
180
|
-
//# sourceMappingURL=junit_formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"junit_formatter.js","sourceRoot":"","sources":["../../src/formatter/junit_formatter.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AAEnC,iDAS2B;AAC3B,oDAAgD;AAChD,oDAAiD;AAEjD,+EAG0C;AAC1C,2DAA0E;AAC1E,0CAAiD;AAiDjD,MAAqB,cAAe,SAAQ,UAAS;IAClC,KAAK,GAA6B,EAAE,CAAA;IACpC,SAAS,CAAQ;IAC3B,MAAM,CAAU,aAAa,GA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MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;iBAC7C;aACF;YACD,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAC5D,CAAC,CAAC,CAAA;QAEF,OAAO,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IACxC,CAAC;;AA5NH,iCA6NC","sourcesContent":["import xmlbuilder from 'xmlbuilder'\nimport * as messages from '@cucumber/messages'\nimport {\n Attachment,\n Duration,\n Feature,\n getWorstTestStepResult,\n Pickle,\n Rule,\n TestStepResult,\n TestStepResultStatus,\n} from '@cucumber/messages'\nimport { doesHaveValue } from '../value_checker'\nimport { valueOrDefault } from '../value_checker'\nimport { ITestCaseAttempt } from './helpers/event_data_collector'\nimport {\n getGherkinExampleRuleMap,\n getGherkinStepMap,\n} from './helpers/gherkin_document_parser'\nimport { getPickleStepMap, getStepKeyword } from './helpers/pickle_parser'\nimport Formatter, { IFormatterOptions } from './'\n\ninterface IJUnitTestSuite {\n name: string\n failures: number\n skipped: number\n time: number\n tests: IJUnitTestCase[]\n}\n\ninterface IJUnitTestCase {\n classname: string\n name: string\n time: number\n result: IJUnitTestCaseResult\n systemOutput: string\n steps: IJUnitTestStep[]\n}\n\ninterface IJUnitTestCaseFailure {\n type: string\n message?: string\n detail: string\n}\n\ninterface IJUnitTestCaseResult {\n status: TestStepResultStatus\n failure?: IJUnitTestCaseFailure\n}\n\ninterface IJUnitTestStep {\n attachments: Attachment[]\n hidden: boolean\n keyword: string\n line: number\n name?: string\n result: TestStepResult\n time: number\n}\n\ninterface IBuildJUnitTestStepOptions {\n isBeforeHook: boolean\n gherkinStepMap: Record<string, messages.Step>\n pickleStepMap: Record<string, messages.PickleStep>\n testStep: messages.TestStep\n testStepAttachments: messages.Attachment[]\n testStepResult: messages.TestStepResult\n}\n\nexport default class JunitFormatter extends Formatter {\n private readonly names: Record<string, string[]> = {}\n private readonly suiteName: string\n public static readonly documentation: string = 'Outputs JUnit report'\n\n constructor(options: IFormatterOptions) {\n super(options)\n this.suiteName = valueOrDefault(\n options.parsedArgvOptions.junit?.suiteName,\n 'cucumber-js'\n )\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n if (doesHaveValue(envelope.testRunFinished)) {\n this.onTestRunFinished()\n }\n })\n }\n\n private getTestCases() {\n return this.eventDataCollector\n .getTestCaseAttempts()\n .filter((attempt) => !attempt.willBeRetried)\n }\n\n private getTestSteps(\n testCaseAttempt: ITestCaseAttempt,\n gherkinStepMap: Record<string, messages.Step>,\n pickleStepMap: Record<string, messages.PickleStep>\n ) {\n return testCaseAttempt.testCase.testSteps.map((testStep) => {\n const isBeforeHook = !doesHaveValue(testStep.pickleStepId)\n return this.getTestStep({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],\n testStepResult: testCaseAttempt.stepResults[testStep.id],\n })\n })\n }\n\n private getTestStep({\n isBeforeHook,\n gherkinStepMap,\n pickleStepMap,\n testStep,\n testStepAttachments,\n testStepResult,\n }: IBuildJUnitTestStepOptions): IJUnitTestStep {\n const data: Partial<IJUnitTestStep> = {}\n if (testStep.pickleStepId) {\n const pickleStep = pickleStepMap[testStep.pickleStepId]\n data.keyword = getStepKeyword({ pickleStep, gherkinStepMap })\n data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line\n data.name = pickleStep.text\n } else {\n data.keyword = isBeforeHook ? 'Before' : 'After'\n data.hidden = true\n }\n data.result = testStepResult\n data.time = testStepResult.duration\n ? this.durationToSeconds(testStepResult.duration)\n : 0\n data.attachments = testStepAttachments\n return data as IJUnitTestStep\n }\n\n private getTestCaseResult(steps: IJUnitTestStep[]): IJUnitTestCaseResult {\n const { status, message, exception } = getWorstTestStepResult(\n steps.map((step) => step.result)\n )\n return {\n status,\n failure:\n message || exception\n ? {\n type: exception?.type,\n message: exception?.message,\n detail: message,\n }\n : undefined,\n }\n }\n\n private durationToSeconds(duration: Duration): number {\n const NANOS_IN_SECOND = 1_000_000_000\n return (\n (duration.seconds * NANOS_IN_SECOND + duration.nanos) / NANOS_IN_SECOND\n )\n }\n\n private nameOrDefault(name: string, fallbackSuffix: string): string {\n if (!name) {\n return `(unnamed ${fallbackSuffix})`\n }\n return name\n }\n\n private getTestCaseName(\n feature: Feature,\n rule: Rule | undefined,\n pickle: Pickle\n ) {\n const featureName = this.nameOrDefault(feature.name, 'feature')\n const pickleName = this.nameOrDefault(pickle.name, 'scenario')\n const testCaseName = rule\n ? this.nameOrDefault(rule.name, 'rule') + ': ' + pickleName\n : pickleName\n if (!this.names[featureName]) {\n this.names[featureName] = []\n }\n let index = 0\n while (\n this.names[featureName].includes(\n index > 0 ? `${testCaseName} [${index}]` : testCaseName\n )\n ) {\n index++\n }\n const name = index > 0 ? `${testCaseName} [${index}]` : testCaseName\n this.names[featureName].push(name)\n return name\n }\n\n private formatTestSteps(steps: IJUnitTestStep[]): string {\n return steps\n .filter((step) => !step.hidden)\n .map((step) => {\n const statusText = step.result.status.toLowerCase()\n const maxLength = 80 - statusText.length - 3\n const stepText = `${step.keyword}${step.name}`\n .padEnd(maxLength, '.')\n .substring(0, maxLength)\n return `${stepText}...${statusText}`\n })\n .join('\\n')\n }\n\n private onTestRunFinished(): void {\n const testCases = this.getTestCases()\n\n const tests = testCases.map<IJUnitTestCase>(\n (testCaseAttempt: ITestCaseAttempt) => {\n const { gherkinDocument, pickle } = testCaseAttempt\n const { feature } = gherkinDocument\n const gherkinExampleRuleMap = getGherkinExampleRuleMap(gherkinDocument)\n const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]]\n const gherkinStepMap = getGherkinStepMap(gherkinDocument)\n const pickleStepMap = getPickleStepMap(pickle)\n\n const steps = this.getTestSteps(\n testCaseAttempt,\n gherkinStepMap,\n pickleStepMap\n )\n const stepDuration = steps.reduce(\n (total, step) => total + (step.time || 0),\n 0\n )\n\n return {\n classname: this.nameOrDefault(feature.name, 'feature'),\n name: this.getTestCaseName(feature, rule, pickle),\n time: stepDuration,\n result: this.getTestCaseResult(steps),\n systemOutput: this.formatTestSteps(steps),\n steps,\n }\n }\n )\n\n const passed = tests.filter(\n (item) => item.result.status === TestStepResultStatus.PASSED\n ).length\n const skipped = tests.filter(\n (item) => item.result.status === TestStepResultStatus.SKIPPED\n ).length\n const failures = tests.length - passed - skipped\n\n const testSuite: IJUnitTestSuite = {\n name: this.suiteName,\n tests,\n failures,\n skipped,\n time: tests.reduce((total, test) => total + test.time, 0),\n }\n\n this.log(this.buildXmlReport(testSuite))\n }\n\n private buildXmlReport(testSuite: IJUnitTestSuite): string {\n const xmlReport = xmlbuilder\n .create('testsuite', { invalidCharReplacement: '' })\n .att('failures', testSuite.failures)\n .att('skipped', testSuite.skipped)\n .att('name', testSuite.name)\n .att('time', testSuite.time)\n .att('tests', testSuite.tests.length)\n testSuite.tests.forEach((test) => {\n const xmlTestCase = xmlReport.ele('testcase', {\n classname: test.classname,\n name: test.name,\n time: test.time,\n })\n if (test.result.status === TestStepResultStatus.SKIPPED) {\n xmlTestCase.ele('skipped')\n } else if (test.result.status !== TestStepResultStatus.PASSED) {\n const xmlFailure = xmlTestCase.ele('failure', {\n type: test.result.failure?.type,\n message: test.result.failure?.message,\n })\n if (test.result?.failure) {\n xmlFailure.cdata(test.result.failure.detail)\n }\n }\n xmlTestCase.ele('system-out', {}).cdata(test.systemOutput)\n })\n\n return xmlReport.end({ pretty: true })\n }\n}\n"]}
|