@cucumber/cucumber 8.8.0 → 8.9.1

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.
@@ -9,7 +9,11 @@ const url_1 = require("url");
9
9
  // eslint-disable-next-line @typescript-eslint/no-var-requires
10
10
  const { importer } = require('../importer');
11
11
  async function getSupportCodeLibrary({ cwd, newId, requireModules, requirePaths, importPaths, }) {
12
- support_code_library_builder_1.default.reset(cwd, newId);
12
+ support_code_library_builder_1.default.reset(cwd, newId, {
13
+ requireModules,
14
+ requirePaths,
15
+ importPaths,
16
+ });
13
17
  requireModules.map((module) => require(module));
14
18
  requirePaths.map((path) => require(path));
15
19
  for (const path of importPaths) {
@@ -1 +1 @@
1
- {"version":3,"file":"support.js","sourceRoot":"","sources":["../../src/api/support.ts"],"names":[],"mappings":";;;;;;AAEA,mGAAuE;AACvE,6BAAmC;AAEnC,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAEpC,KAAK,UAAU,qBAAqB,CAAC,EAC1C,GAAG,EACH,KAAK,EACL,cAAc,EACd,YAAY,EACZ,WAAW,GAOZ;IACC,sCAAyB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IAC3C,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/C,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IACzC,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE;QAC9B,MAAM,QAAQ,CAAC,IAAA,mBAAa,EAAC,IAAI,CAAC,CAAC,CAAA;KACpC;IACD,OAAO,sCAAyB,CAAC,QAAQ,EAAE,CAAA;AAC7C,CAAC;AApBD,sDAoBC","sourcesContent":["import { IdGenerator } from '@cucumber/messages'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport supportCodeLibraryBuilder from '../support_code_library_builder'\nimport { pathToFileURL } from 'url'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\nexport async function getSupportCodeLibrary({\n cwd,\n newId,\n requireModules,\n requirePaths,\n importPaths,\n}: {\n cwd: string\n newId: IdGenerator.NewId\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}): Promise<ISupportCodeLibrary> {\n supportCodeLibraryBuilder.reset(cwd, newId)\n requireModules.map((module) => require(module))\n requirePaths.map((path) => require(path))\n for (const path of importPaths) {\n await importer(pathToFileURL(path))\n }\n return supportCodeLibraryBuilder.finalize()\n}\n"]}
1
+ {"version":3,"file":"support.js","sourceRoot":"","sources":["../../src/api/support.ts"],"names":[],"mappings":";;;;;;AAEA,mGAAuE;AACvE,6BAAmC;AAEnC,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAEpC,KAAK,UAAU,qBAAqB,CAAC,EAC1C,GAAG,EACH,KAAK,EACL,cAAc,EACd,YAAY,EACZ,WAAW,GAOZ;IACC,sCAAyB,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE;QAC1C,cAAc;QACd,YAAY;QACZ,WAAW;KACZ,CAAC,CAAA;IACF,cAAc,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/C,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IACzC,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE;QAC9B,MAAM,QAAQ,CAAC,IAAA,mBAAa,EAAC,IAAI,CAAC,CAAC,CAAA;KACpC;IACD,OAAO,sCAAyB,CAAC,QAAQ,EAAE,CAAA;AAC7C,CAAC;AAxBD,sDAwBC","sourcesContent":["import { IdGenerator } from '@cucumber/messages'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport supportCodeLibraryBuilder from '../support_code_library_builder'\nimport { pathToFileURL } from 'url'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\nexport async function getSupportCodeLibrary({\n cwd,\n newId,\n requireModules,\n requirePaths,\n importPaths,\n}: {\n cwd: string\n newId: IdGenerator.NewId\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}): Promise<ISupportCodeLibrary> {\n supportCodeLibraryBuilder.reset(cwd, newId, {\n requireModules,\n requirePaths,\n importPaths,\n })\n requireModules.map((module) => require(module))\n requirePaths.map((path) => require(path))\n for (const path of importPaths) {\n await importer(pathToFileURL(path))\n }\n return supportCodeLibraryBuilder.finalize()\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { IRunEnvironment } from './types';
2
+ export declare function setupEnvironment(): Promise<Partial<IRunEnvironment>>;
3
+ export declare function teardownEnvironment(environment: IRunEnvironment): Promise<void>;
@@ -0,0 +1,33 @@
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
+ exports.teardownEnvironment = exports.setupEnvironment = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = __importDefault(require("mz/fs"));
9
+ const reindent_template_literals_1 = require("reindent-template-literals");
10
+ const stream_1 = require("stream");
11
+ const messages_1 = require("@cucumber/messages");
12
+ const newId = messages_1.IdGenerator.uuid();
13
+ async function setupEnvironment() {
14
+ const cwd = path_1.default.join(__dirname, '..', '..', 'tmp', `api_${newId()}`);
15
+ await fs_1.default.mkdir(path_1.default.join(cwd, 'features'), { recursive: true });
16
+ await fs_1.default.writeFile(path_1.default.join(cwd, 'features', 'test.feature'), (0, reindent_template_literals_1.reindent)(`Feature: test fixture
17
+ Scenario: one
18
+ Given a step
19
+ Then another step`));
20
+ await fs_1.default.writeFile(path_1.default.join(cwd, 'features', 'steps.ts'), (0, reindent_template_literals_1.reindent)(`import { Given, Then } from '../../../src'
21
+ Given('a step', function () {})
22
+ Then('another step', function () {})`));
23
+ await fs_1.default.writeFile(path_1.default.join(cwd, 'cucumber.mjs'), `export default {paths: ['features/test.feature'], requireModule: ['ts-node/register'], require: ['features/steps.ts']}`);
24
+ const stdout = new stream_1.PassThrough();
25
+ return { cwd, stdout };
26
+ }
27
+ exports.setupEnvironment = setupEnvironment;
28
+ async function teardownEnvironment(environment) {
29
+ await fs_1.default.rmdir(environment.cwd, { recursive: true });
30
+ environment.stdout.end();
31
+ }
32
+ exports.teardownEnvironment = teardownEnvironment;
33
+ //# sourceMappingURL=test_helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_helpers.js","sourceRoot":"","sources":["../../src/api/test_helpers.ts"],"names":[],"mappings":";;;;;;AACA,gDAAuB;AACvB,+CAAsB;AACtB,2EAAqD;AACrD,mCAAoC;AACpC,iDAAgD;AAEhD,MAAM,KAAK,GAAG,sBAAW,CAAC,IAAI,EAAE,CAAA;AAEzB,KAAK,UAAU,gBAAgB;IACpC,MAAM,GAAG,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,KAAK,EAAE,EAAE,CAAC,CAAA;IACrE,MAAM,YAAE,CAAC,KAAK,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/D,MAAM,YAAE,CAAC,SAAS,CAChB,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,cAAc,CAAC,EAC1C,IAAA,qCAAQ,EAAC;;;0BAGa,CAAC,CACxB,CAAA;IACD,MAAM,YAAE,CAAC,SAAS,CAChB,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC,EACtC,IAAA,qCAAQ,EAAC;;yCAE4B,CAAC,CACvC,CAAA;IACD,MAAM,YAAE,CAAC,SAAS,CAChB,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,EAC9B,wHAAwH,CACzH,CAAA;IACD,MAAM,MAAM,GAAG,IAAI,oBAAW,EAAE,CAAA;IAChC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA;AACxB,CAAC;AAtBD,4CAsBC;AAEM,KAAK,UAAU,mBAAmB,CAAC,WAA4B;IACpE,MAAM,YAAE,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;AAC1B,CAAC;AAHD,kDAGC","sourcesContent":["import { IRunEnvironment } from './types'\nimport path from 'path'\nimport fs from 'mz/fs'\nimport { reindent } from 'reindent-template-literals'\nimport { PassThrough } from 'stream'\nimport { IdGenerator } from '@cucumber/messages'\n\nconst newId = IdGenerator.uuid()\n\nexport async function setupEnvironment(): Promise<Partial<IRunEnvironment>> {\n const cwd = path.join(__dirname, '..', '..', 'tmp', `api_${newId()}`)\n await fs.mkdir(path.join(cwd, 'features'), { recursive: true })\n await fs.writeFile(\n path.join(cwd, 'features', 'test.feature'),\n reindent(`Feature: test fixture\n Scenario: one\n Given a step\n Then another step`)\n )\n await fs.writeFile(\n path.join(cwd, 'features', 'steps.ts'),\n reindent(`import { Given, Then } from '../../../src'\n Given('a step', function () {})\n Then('another step', function () {})`)\n )\n await fs.writeFile(\n path.join(cwd, 'cucumber.mjs'),\n `export default {paths: ['features/test.feature'], requireModule: ['ts-node/register'], require: ['features/steps.ts']}`\n )\n const stdout = new PassThrough()\n return { cwd, stdout }\n}\n\nexport async function teardownEnvironment(environment: IRunEnvironment) {\n await fs.rmdir(environment.cwd, { recursive: true })\n environment.stdout.end()\n}\n"]}
@@ -117,7 +117,7 @@ export interface IRunConfiguration {
117
117
  /**
118
118
  * @public
119
119
  */
120
- export declare type ISupportCodeCoordinatesOrLibrary = ISupportCodeCoordinates | ISupportCodeLibrary;
120
+ export type ISupportCodeCoordinatesOrLibrary = ISupportCodeCoordinates | ISupportCodeLibrary;
121
121
  /**
122
122
  * @public
123
123
  */
@@ -1,4 +1,4 @@
1
- declare type PackageJSON = {
1
+ type PackageJSON = {
2
2
  engines: {
3
3
  node: string;
4
4
  };
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  import { TestStepResultStatus } from '@cucumber/messages';
4
4
  import { Writable } from 'stream';
5
- export declare type IColorFn = (text: string) => string;
5
+ export type IColorFn = (text: string) => string;
6
6
  export interface IColorFns {
7
7
  forStatus: (status: TestStepResultStatus) => IColorFn;
8
8
  location: IColorFn;
@@ -13,6 +13,7 @@ const summary_formatter_1 = __importDefault(require("../summary_formatter"));
13
13
  const usage_formatter_1 = __importDefault(require("../usage_formatter"));
14
14
  const usage_json_formatter_1 = __importDefault(require("../usage_json_formatter"));
15
15
  const html_formatter_1 = __importDefault(require("../html_formatter"));
16
+ const junit_formatter_1 = __importDefault(require("../junit_formatter"));
16
17
  const Formatters = {
17
18
  getFormatters() {
18
19
  return {
@@ -26,6 +27,7 @@ const Formatters = {
26
27
  summary: summary_formatter_1.default,
27
28
  usage: usage_formatter_1.default,
28
29
  'usage-json': usage_json_formatter_1.default,
30
+ junit: junit_formatter_1.default,
29
31
  };
30
32
  },
31
33
  buildFormattersDocumentationString() {
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/formatter/helpers/formatters.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,6EAAmD;AACnD,uFAA4D;AAC5D,+EAAqD;AACrD,yEAA+C;AAC/C,+EAAqD;AACrD,6EAAmD;AACnD,yEAA+C;AAC/C,mFAAwD;AACxD,uEAA6C;AAE7C,MAAM,UAAU,GAAG;IACjB,aAAa;QACX,OAAO;YACL,IAAI,EAAE,wBAAa;YACnB,OAAO,EAAE,2BAAgB;YACzB,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;IACD,kCAAkC;QAChC,IAAI,mCAAmC,GAAW,EAAE,CAAA;QACpD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QACvC,KAAK,MAAM,aAAa,IAAI,UAAU,EAAE;YACtC,mCAAmC,IAAI,OAAO,aAAa,KAAK,UAAU,CAAC,aAAa,CAAC,CAAC,aAAa,IAAI,CAAA;SAC5G;QAED,OAAO,mCAAmC,CAAA;IAC5C,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import Formatter from '../.'\nimport JsonFormatter from '../json_formatter'\nimport MessageFormatter from '../message_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'\nimport HtmlFormatter from '../html_formatter'\n\nconst Formatters = {\n getFormatters(): Record<string, typeof Formatter> {\n return {\n json: JsonFormatter,\n message: MessageFormatter,\n html: HtmlFormatter,\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 buildFormattersDocumentationString(): string {\n let concatanatedFormattersDocumentation: string = ''\n const formatters = this.getFormatters()\n for (const formatterName in formatters) {\n concatanatedFormattersDocumentation += ` ${formatterName}: ${formatters[formatterName].documentation}\\n`\n }\n\n return concatanatedFormattersDocumentation\n },\n}\n\nexport default Formatters\n"]}
1
+ {"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/formatter/helpers/formatters.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,6EAAmD;AACnD,uFAA4D;AAC5D,+EAAqD;AACrD,yEAA+C;AAC/C,+EAAqD;AACrD,6EAAmD;AACnD,yEAA+C;AAC/C,mFAAwD;AACxD,uEAA6C;AAC7C,yEAA+C;AAE/C,MAAM,UAAU,GAAG;IACjB,aAAa;QACX,OAAO;YACL,IAAI,EAAE,wBAAa;YACnB,OAAO,EAAE,2BAAgB;YACzB,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;YAChC,KAAK,EAAE,yBAAc;SACtB,CAAA;IACH,CAAC;IACD,kCAAkC;QAChC,IAAI,mCAAmC,GAAW,EAAE,CAAA;QACpD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QACvC,KAAK,MAAM,aAAa,IAAI,UAAU,EAAE;YACtC,mCAAmC,IAAI,OAAO,aAAa,KAAK,UAAU,CAAC,aAAa,CAAC,CAAC,aAAa,IAAI,CAAA;SAC5G;QAED,OAAO,mCAAmC,CAAA;IAC5C,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import Formatter from '../.'\nimport JsonFormatter from '../json_formatter'\nimport MessageFormatter from '../message_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'\nimport HtmlFormatter from '../html_formatter'\nimport JunitFormatter from '../junit_formatter'\n\nconst Formatters = {\n getFormatters(): Record<string, typeof Formatter> {\n return {\n json: JsonFormatter,\n message: MessageFormatter,\n html: HtmlFormatter,\n progress: ProgressFormatter,\n 'progress-bar': ProgressBarFormatter,\n rerun: RerunFormatter,\n snippets: SnippetsFormatter,\n summary: SummaryFormatter,\n usage: UsageFormatter,\n 'usage-json': UsageJsonFormatter,\n junit: JunitFormatter,\n }\n },\n buildFormattersDocumentationString(): string {\n let concatanatedFormattersDocumentation: string = ''\n const formatters = this.getFormatters()\n for (const formatterName in formatters) {\n concatanatedFormattersDocumentation += ` ${formatterName}: ${formatters[formatterName].documentation}\\n`\n }\n\n return concatanatedFormattersDocumentation\n },\n}\n\nexport default Formatters\n"]}
@@ -22,9 +22,9 @@ export interface IPublishConfig {
22
22
  url: string;
23
23
  token: string;
24
24
  }
25
- export declare type IFormatterStream = Writable;
26
- export declare type IFormatterLogFn = (buffer: string | Uint8Array) => void;
27
- export declare type IFormatterCleanupFn = () => Promise<any>;
25
+ export type IFormatterStream = Writable;
26
+ export type IFormatterLogFn = (buffer: string | Uint8Array) => void;
27
+ export type IFormatterCleanupFn = () => Promise<any>;
28
28
  export interface IFormatterOptions {
29
29
  colorFns: IColorFns;
30
30
  cwd: string;
@@ -0,0 +1,16 @@
1
+ import Formatter, { IFormatterOptions } from './';
2
+ export default class JunitFormatter extends Formatter {
3
+ private readonly names;
4
+ static readonly documentation: string;
5
+ constructor(options: IFormatterOptions);
6
+ private getTestCases;
7
+ private getTestSteps;
8
+ private getTestStep;
9
+ private getTestCaseResult;
10
+ private durationToSeconds;
11
+ private nameOrDefault;
12
+ private getTestCaseName;
13
+ private formatTestSteps;
14
+ private onTestRunFinished;
15
+ private buildXmlReport;
16
+ }
@@ -0,0 +1,177 @@
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 _1 = __importDefault(require("./"));
8
+ const messages_1 = require("@cucumber/messages");
9
+ const value_checker_1 = 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 statusDescriptions = {
13
+ UNKNOWN: `A result couldn't be established`,
14
+ PASSED: 'Everything went fine',
15
+ SKIPPED: 'The test case was skipped',
16
+ PENDING: 'A step in the test case is not yet implemented',
17
+ UNDEFINED: 'A step in the test case is not defined',
18
+ AMBIGUOUS: 'Multiple definitions match one of the steps in the test case',
19
+ FAILED: 'A hook or step failed',
20
+ };
21
+ class JunitFormatter extends _1.default {
22
+ constructor(options) {
23
+ super(options);
24
+ this.names = {};
25
+ options.eventBroadcaster.on('envelope', (envelope) => {
26
+ if ((0, value_checker_1.doesHaveValue)(envelope.testRunFinished)) {
27
+ this.onTestRunFinished();
28
+ }
29
+ });
30
+ }
31
+ getTestCases() {
32
+ return this.eventDataCollector
33
+ .getTestCaseAttempts()
34
+ .filter((attempt) => !attempt.willBeRetried);
35
+ }
36
+ getTestSteps(testCaseAttempt, gherkinStepMap, pickleStepMap) {
37
+ return testCaseAttempt.testCase.testSteps.map((testStep) => {
38
+ const isBeforeHook = !(0, value_checker_1.doesHaveValue)(testStep.pickleStepId);
39
+ return this.getTestStep({
40
+ isBeforeHook,
41
+ gherkinStepMap,
42
+ pickleStepMap,
43
+ testStep,
44
+ testStepAttachments: testCaseAttempt.stepAttachments[testStep.id],
45
+ testStepResult: testCaseAttempt.stepResults[testStep.id],
46
+ });
47
+ });
48
+ }
49
+ getTestStep({ isBeforeHook, gherkinStepMap, pickleStepMap, testStep, testStepAttachments, testStepResult, }) {
50
+ const data = {};
51
+ if (testStep.pickleStepId) {
52
+ const pickleStep = pickleStepMap[testStep.pickleStepId];
53
+ data.keyword = (0, pickle_parser_1.getStepKeyword)({ pickleStep, gherkinStepMap });
54
+ data.line = gherkinStepMap[pickleStep.astNodeIds[0]].location.line;
55
+ data.name = pickleStep.text;
56
+ }
57
+ else {
58
+ data.keyword = isBeforeHook ? 'Before' : 'After';
59
+ data.hidden = true;
60
+ }
61
+ data.result = testStepResult;
62
+ data.time = testStepResult.duration
63
+ ? this.durationToSeconds(testStepResult.duration)
64
+ : 0;
65
+ data.attachments = testStepAttachments;
66
+ return data;
67
+ }
68
+ getTestCaseResult(steps) {
69
+ const worstResult = (0, messages_1.getWorstTestStepResult)(steps.map((step) => step.result));
70
+ return worstResult;
71
+ }
72
+ durationToSeconds(duration) {
73
+ const NANOS_IN_SECOND = 1000000000;
74
+ return ((duration.seconds * NANOS_IN_SECOND + duration.nanos) / NANOS_IN_SECOND);
75
+ }
76
+ nameOrDefault(name, fallbackSuffix) {
77
+ if (!name) {
78
+ return `(unnamed ${fallbackSuffix})`;
79
+ }
80
+ return name;
81
+ }
82
+ getTestCaseName(feature, rule, pickle) {
83
+ const featureName = this.nameOrDefault(feature.name, 'feature');
84
+ const pickleName = this.nameOrDefault(pickle.name, 'scenario');
85
+ const testCaseName = rule
86
+ ? this.nameOrDefault(rule.name, 'rule') + ': ' + pickleName
87
+ : pickleName;
88
+ if (!this.names[featureName]) {
89
+ this.names[featureName] = [];
90
+ }
91
+ let index = 0;
92
+ while (this.names[featureName].includes(index > 0 ? `${testCaseName} [${index}]` : testCaseName)) {
93
+ index++;
94
+ }
95
+ const name = index > 0 ? `${testCaseName} [${index}]` : testCaseName;
96
+ this.names[featureName].push(name);
97
+ return name;
98
+ }
99
+ formatTestSteps(steps) {
100
+ return steps
101
+ .filter((step) => !step.hidden)
102
+ .map((step) => {
103
+ const statusText = step.result.status.toLowerCase();
104
+ const maxLength = 80 - statusText.length - 3;
105
+ const stepText = `${step.keyword}${step.name}`
106
+ .padEnd(maxLength, '.')
107
+ .substring(0, maxLength);
108
+ return `${stepText}...${statusText}`;
109
+ })
110
+ .join('\n');
111
+ }
112
+ onTestRunFinished() {
113
+ const testCases = this.getTestCases();
114
+ const tests = testCases.map((testCaseAttempt) => {
115
+ const { gherkinDocument, pickle } = testCaseAttempt;
116
+ const { feature } = gherkinDocument;
117
+ const gherkinExampleRuleMap = (0, gherkin_document_parser_1.getGherkinExampleRuleMap)(gherkinDocument);
118
+ const rule = gherkinExampleRuleMap[pickle.astNodeIds[0]];
119
+ const gherkinStepMap = (0, gherkin_document_parser_1.getGherkinStepMap)(gherkinDocument);
120
+ const pickleStepMap = (0, pickle_parser_1.getPickleStepMap)(pickle);
121
+ const steps = this.getTestSteps(testCaseAttempt, gherkinStepMap, pickleStepMap);
122
+ const stepDuration = steps.reduce((total, step) => total + (step.time || 0), 0);
123
+ return {
124
+ classname: this.nameOrDefault(feature.name, 'feature'),
125
+ name: this.getTestCaseName(feature, rule, pickle),
126
+ time: stepDuration,
127
+ result: this.getTestCaseResult(steps),
128
+ systemOutput: this.formatTestSteps(steps),
129
+ steps,
130
+ };
131
+ });
132
+ const passed = tests.filter((item) => item.result.status === messages_1.TestStepResultStatus.PASSED).length;
133
+ const skipped = tests.filter((item) => item.result.status === messages_1.TestStepResultStatus.SKIPPED).length;
134
+ const failures = tests.length - passed - skipped;
135
+ const testSuite = {
136
+ name: 'cucumber-js',
137
+ tests,
138
+ failures,
139
+ skipped,
140
+ time: tests.reduce((total, test) => total + test.time, 0),
141
+ };
142
+ this.log(this.buildXmlReport(testSuite));
143
+ }
144
+ buildXmlReport(testSuite) {
145
+ const xmlReport = xmlbuilder_1.default
146
+ .create('testsuite')
147
+ .att('failures', testSuite.failures)
148
+ .att('skipped', testSuite.skipped)
149
+ .att('name', testSuite.name)
150
+ .att('time', testSuite.time)
151
+ .att('tests', testSuite.tests.length);
152
+ testSuite.tests.forEach((test) => {
153
+ const xmlTestCase = xmlReport.ele('testcase', {
154
+ classname: test.classname,
155
+ name: test.name,
156
+ time: test.time,
157
+ });
158
+ if (test.result.status === messages_1.TestStepResultStatus.SKIPPED) {
159
+ xmlTestCase.ele('skipped');
160
+ }
161
+ else if (test.result.status !== messages_1.TestStepResultStatus.PASSED) {
162
+ const xmlFailure = xmlTestCase.ele('failure', {
163
+ type: test.result.status,
164
+ message: statusDescriptions[test.result.status],
165
+ });
166
+ if (test.result.message) {
167
+ xmlFailure.cdata(test.result.message);
168
+ }
169
+ }
170
+ xmlTestCase.ele('system-out', {}).cdata(test.systemOutput);
171
+ });
172
+ return xmlReport.end({ pretty: true });
173
+ }
174
+ }
175
+ exports.default = JunitFormatter;
176
+ JunitFormatter.documentation = 'Outputs JUnit report';
177
+ //# sourceMappingURL=junit_formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"junit_formatter.js","sourceRoot":"","sources":["../../src/formatter/junit_formatter.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AACnC,0CAAiD;AAEjD,iDAS2B;AAE3B,oDAAgD;AAChD,+EAG0C;AAC1C,2DAA0E;AA2C1E,MAAM,kBAAkB,GAAyC;IAC/D,OAAO,EAAE,kCAAkC;IAC3C,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE,2BAA2B;IACpC,OAAO,EAAE,gDAAgD;IACzD,SAAS,EAAE,wCAAwC;IACnD,SAAS,EAAE,8DAA8D;IACzE,MAAM,EAAE,uBAAuB;CAChC,CAAA;AAED,MAAqB,cAAe,SAAQ,UAAS;IAInD,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QAJC,UAAK,GAA6B,EAAE,CAAA;QAKnD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;gBAC3C,IAAI,CAAC,iBAAiB,EAAE,CAAA;aACzB;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,YAAY;QAClB,OAAO,IAAI,CAAC,kBAA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I,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,+BAAoB,CAAC,OAAO,EAAE;gBACvD,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;aAC3B;iBAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,+BAAoB,CAAC,MAAM,EAAE;gBAC7D,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE;oBAC5C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;oBACxB,OAAO,EAAE,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;iBAChD,CAAC,CAAA;gBACF,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;oBACvB,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;iBACtC;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;;AA3MH,iCA4MC;AA1MwB,4BAAa,GAAW,sBAAsB,CAAA","sourcesContent":["import xmlbuilder from 'xmlbuilder'\nimport Formatter, { IFormatterOptions } from './'\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 { ITestCaseAttempt } from './helpers/event_data_collector'\nimport { doesHaveValue } from '../value_checker'\nimport {\n getGherkinExampleRuleMap,\n getGherkinStepMap,\n} from './helpers/gherkin_document_parser'\nimport { getPickleStepMap, getStepKeyword } from './helpers/pickle_parser'\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 IJUnitTestCaseResult {\n status: TestStepResultStatus\n message?: string\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\nconst statusDescriptions: Record<TestStepResultStatus, string> = {\n UNKNOWN: `A result couldn't be established`,\n PASSED: 'Everything went fine',\n SKIPPED: 'The test case was skipped',\n PENDING: 'A step in the test case is not yet implemented',\n UNDEFINED: 'A step in the test case is not defined',\n AMBIGUOUS: 'Multiple definitions match one of the steps in the test case',\n FAILED: 'A hook or step failed',\n}\n\nexport default class JunitFormatter extends Formatter {\n private readonly names: Record<string, string[]> = {}\n public static readonly documentation: string = 'Outputs JUnit report'\n\n constructor(options: IFormatterOptions) {\n super(options)\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 worstResult = getWorstTestStepResult(steps.map((step) => step.result))\n return worstResult\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: 'cucumber-js',\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')\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.status,\n message: statusDescriptions[test.result.status],\n })\n if (test.result.message) {\n xmlFailure.cdata(test.result.message)\n }\n }\n xmlTestCase.ele('system-out', {}).cdata(test.systemOutput)\n })\n\n return xmlReport.end({ pretty: true })\n }\n}\n"]}
@@ -1 +1 @@
1
- export declare type GherkinStepKeyword = 'Unknown' | 'Given' | 'When' | 'Then';
1
+ export type GherkinStepKeyword = 'Unknown' | 'Given' | 'When' | 'Then';
@@ -1 +1 @@
1
- export declare type PickleOrder = 'defined' | 'random' | string;
1
+ export type PickleOrder = 'defined' | 'random' | string;
@@ -10,5 +10,5 @@ export interface PluginContext {
10
10
  configuration: IRunOptions;
11
11
  environment: IRunEnvironment;
12
12
  }
13
- export declare type PluginCleanup = () => any | void | Promise<any | void>;
14
- export declare type Plugin = (context: PluginContext) => Promise<PluginCleanup | void>;
13
+ export type PluginCleanup = () => any | void | Promise<any | void>;
14
+ export type Plugin = (context: PluginContext) => Promise<PluginCleanup | void>;
@@ -3,7 +3,7 @@
3
3
  /// <reference types="node" />
4
4
  import { Transform } from 'stream';
5
5
  import http from 'http';
6
- declare type HttpMethod = 'GET' | 'POST' | 'PUT';
6
+ type HttpMethod = 'GET' | 'POST' | 'PUT';
7
7
  /**
8
8
  * This Writable writes data to a HTTP/HTTPS URL.
9
9
  *
@@ -10,9 +10,9 @@ export interface IAttachment {
10
10
  data: string;
11
11
  media: IAttachmentMedia;
12
12
  }
13
- export declare type IAttachFunction = (attachment: IAttachment) => void;
14
- export declare type ICreateAttachment = (data: Buffer | Readable | string, mediaType?: string, callback?: () => void) => void | Promise<void>;
15
- export declare type ICreateLog = (text: string) => void | Promise<void>;
13
+ export type IAttachFunction = (attachment: IAttachment) => void;
14
+ export type ICreateAttachment = (data: Buffer | Readable | string, mediaType?: string, callback?: () => void) => void | Promise<void>;
15
+ export type ICreateLog = (text: string) => void | Promise<void>;
16
16
  export default class AttachmentManager {
17
17
  private readonly onAttachment;
18
18
  constructor(onAttachment: IAttachFunction);
@@ -1,6 +1,6 @@
1
1
  import { ICoordinatorReport, IWorkerCommand, IWorkerCommandInitialize, IWorkerCommandRun } from './command_types';
2
- declare type IExitFunction = (exitCode: number, error?: Error, message?: string) => void;
3
- declare type IMessageSender = (command: ICoordinatorReport) => void;
2
+ type IExitFunction = (exitCode: number, error?: Error, message?: string) => void;
3
+ type IMessageSender = (command: ICoordinatorReport) => void;
4
4
  export default class Worker {
5
5
  private readonly cwd;
6
6
  private readonly exit;
@@ -32,7 +32,11 @@ class Worker {
32
32
  });
33
33
  }
34
34
  async initialize({ filterStacktraces, requireModules, requirePaths, importPaths, supportCodeIds, options, }) {
35
- support_code_library_builder_1.default.reset(this.cwd, this.newId);
35
+ support_code_library_builder_1.default.reset(this.cwd, this.newId, {
36
+ requireModules,
37
+ requirePaths,
38
+ importPaths,
39
+ });
36
40
  requireModules.map((module) => require(module));
37
41
  requirePaths.map((module) => require(module));
38
42
  for (const path of importPaths) {
@@ -1 +1 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/worker.ts"],"names":[],"mappings":";;;;;AACA,iDAAgD;AAChD,yCAAoC;AACpC,mCAAqC;AACrC,6BAAmC;AACnC,sGAA0E;AAE1E,uDAAmD;AACnD,8DAA6E;AAC7E,4CAAmD;AACnD,2EAAgD;AAQhD,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,sBAAW,CAAA;AAK5B,MAAqB,MAAM;IAazB,YAAY,EACV,GAAG,EACH,IAAI,EACJ,EAAE,EACF,WAAW,GAMZ;QACC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,CAAA;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;Q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AK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM;YACN,QAAQ;YACR,OAAO;YACP,IAAI;YACJ,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAA;QACF,MAAM,cAAc,CAAC,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACnC,CAAC;CACF;AAlHD,yBAkHC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { duration } from 'durations'\nimport { EventEmitter } from 'events'\nimport { pathToFileURL } from 'url'\nimport supportCodeLibraryBuilder from '../../support_code_library_builder'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { doesHaveValue } from '../../value_checker'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from '../run_test_run_hooks'\nimport { RealTestRunStopwatch } from '../stopwatch'\nimport TestCaseRunner from '../test_case_runner'\nimport {\n ICoordinatorReport,\n IWorkerCommand,\n IWorkerCommandInitialize,\n IWorkerCommandRun,\n} from './command_types'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../../importer')\nconst { uuid } = IdGenerator\n\ntype IExitFunction = (exitCode: number, error?: Error, message?: string) => void\ntype IMessageSender = (command: ICoordinatorReport) => void\n\nexport default class Worker {\n private readonly cwd: string\n private readonly exit: IExitFunction\n\n private readonly id: string\n private readonly eventBroadcaster: EventEmitter\n private filterStacktraces: boolean\n private readonly newId: IdGenerator.NewId\n private readonly sendMessage: IMessageSender\n private supportCodeLibrary: ISupportCodeLibrary\n private worldParameters: any\n private runTestRunHooks: RunsTestRunHooks\n\n constructor({\n cwd,\n exit,\n id,\n sendMessage,\n }: {\n cwd: string\n exit: IExitFunction\n id: string\n sendMessage: IMessageSender\n }) {\n this.id = id\n this.newId = uuid()\n this.cwd = cwd\n this.exit = exit\n this.sendMessage = sendMessage\n this.eventBroadcaster = new EventEmitter()\n this.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n // assign `workerId` property only for the `testCaseStarted` message\n if (envelope.testCaseStarted) {\n envelope.testCaseStarted.workerId = this.id\n }\n this.sendMessage({ jsonEnvelope: JSON.stringify(envelope) })\n })\n }\n\n async initialize({\n filterStacktraces,\n requireModules,\n requirePaths,\n importPaths,\n supportCodeIds,\n options,\n }: IWorkerCommandInitialize): Promise<void> {\n supportCodeLibraryBuilder.reset(this.cwd, this.newId)\n requireModules.map((module) => require(module))\n requirePaths.map((module) => require(module))\n for (const path of importPaths) {\n await importer(pathToFileURL(path))\n }\n this.supportCodeLibrary = supportCodeLibraryBuilder.finalize(supportCodeIds)\n\n this.worldParameters = options.worldParameters\n this.filterStacktraces = filterStacktraces\n this.runTestRunHooks = makeRunTestRunHooks(\n options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n (name, location) =>\n `${name} hook errored on worker ${this.id}, process exiting: ${location}`\n )\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n this.sendMessage({ ready: true })\n }\n\n async finalize(): Promise<void> {\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions,\n 'an AfterAll'\n )\n this.exit(0)\n }\n\n async receiveMessage(message: IWorkerCommand): Promise<void> {\n if (doesHaveValue(message.initialize)) {\n await this.initialize(message.initialize)\n } else if (message.finalize) {\n await this.finalize()\n } else if (doesHaveValue(message.run)) {\n await this.runTestCase(message.run)\n }\n }\n\n async runTestCase({\n gherkinDocument,\n pickle,\n testCase,\n elapsed,\n retries,\n skip,\n }: IWorkerCommandRun): Promise<void> {\n const stopwatch = new RealTestRunStopwatch()\n stopwatch.from(duration(elapsed))\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n filterStackTraces: this.filterStacktraces,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.worldParameters,\n })\n await testCaseRunner.run()\n this.sendMessage({ ready: true })\n }\n}\n"]}
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/worker.ts"],"names":[],"mappings":";;;;;AACA,iDAAgD;AAChD,yCAAoC;AACpC,mCAAqC;AACrC,6BAAmC;AACnC,sGAA0E;AAE1E,uDAAmD;AACnD,8DAA6E;AAC7E,4CAAmD;AACnD,2EAAgD;AAQhD,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAC9C,MAAM,EAAE,IAAI,EAAE,GAAG,sBAAW,CAAA;AAK5B,MAAqB,MAAM;IAazB,YAAY,EACV,GAAG,EACH,IAAI,EACJ,EAAE,EACF,WAAW,GAMZ;QACC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,CAAA;QACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,gBAAgB,GAAG,IAAI,qBAAY,EAAE,CAAA;QAC1C,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACnE,oEAAoE;YACpE,IAAI,QAAQ,CAAC,eAAe,EAAE;gBAC5B,QAAQ,CAAC,eAAe,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAA;aAC5C;YACD,IAAI,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAC9D,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC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AAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACd,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAuB;QAC1C,IAAI,IAAA,6BAAa,EAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YACrC,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SAC1C;aAAM,IAAI,OAAO,CAAC,QAAQ,EAAE;YAC3B,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAA;SACtB;aAAM,IAAI,IAAA,6BAAa,EAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACrC,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;SACpC;IACH,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAChB,eAAe,EACf,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,GACc;QAClB,MAAM,SAAS,GAAG,IAAI,gCAAoB,EAAE,CAAA;QAC5C,SAAS,CAAC,IAAI,CAAC,IAAA,oBAAQ,EAAC,OAAO,CAAC,CAAC,CAAA;QACjC,MAAM,cAAc,GAAG,IAAI,0BAAc,CAAC;YACxC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,SAAS;YACT,eAAe;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM;YACN,QAAQ;YACR,OAAO;YACP,IAAI;YACJ,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAA;QACF,MAAM,cAAc,CAAC,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACnC,CAAC;CACF;AAtHD,yBAsHC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { duration } from 'durations'\nimport { EventEmitter } from 'events'\nimport { pathToFileURL } from 'url'\nimport supportCodeLibraryBuilder from '../../support_code_library_builder'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { doesHaveValue } from '../../value_checker'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from '../run_test_run_hooks'\nimport { RealTestRunStopwatch } from '../stopwatch'\nimport TestCaseRunner from '../test_case_runner'\nimport {\n ICoordinatorReport,\n IWorkerCommand,\n IWorkerCommandInitialize,\n IWorkerCommandRun,\n} from './command_types'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../../importer')\nconst { uuid } = IdGenerator\n\ntype IExitFunction = (exitCode: number, error?: Error, message?: string) => void\ntype IMessageSender = (command: ICoordinatorReport) => void\n\nexport default class Worker {\n private readonly cwd: string\n private readonly exit: IExitFunction\n\n private readonly id: string\n private readonly eventBroadcaster: EventEmitter\n private filterStacktraces: boolean\n private readonly newId: IdGenerator.NewId\n private readonly sendMessage: IMessageSender\n private supportCodeLibrary: ISupportCodeLibrary\n private worldParameters: any\n private runTestRunHooks: RunsTestRunHooks\n\n constructor({\n cwd,\n exit,\n id,\n sendMessage,\n }: {\n cwd: string\n exit: IExitFunction\n id: string\n sendMessage: IMessageSender\n }) {\n this.id = id\n this.newId = uuid()\n this.cwd = cwd\n this.exit = exit\n this.sendMessage = sendMessage\n this.eventBroadcaster = new EventEmitter()\n this.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n // assign `workerId` property only for the `testCaseStarted` message\n if (envelope.testCaseStarted) {\n envelope.testCaseStarted.workerId = this.id\n }\n this.sendMessage({ jsonEnvelope: JSON.stringify(envelope) })\n })\n }\n\n async initialize({\n filterStacktraces,\n requireModules,\n requirePaths,\n importPaths,\n supportCodeIds,\n options,\n }: IWorkerCommandInitialize): Promise<void> {\n supportCodeLibraryBuilder.reset(this.cwd, this.newId, {\n requireModules,\n requirePaths,\n importPaths,\n })\n requireModules.map((module) => require(module))\n requirePaths.map((module) => require(module))\n for (const path of importPaths) {\n await importer(pathToFileURL(path))\n }\n this.supportCodeLibrary = supportCodeLibraryBuilder.finalize(supportCodeIds)\n\n this.worldParameters = options.worldParameters\n this.filterStacktraces = filterStacktraces\n this.runTestRunHooks = makeRunTestRunHooks(\n options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n (name, location) =>\n `${name} hook errored on worker ${this.id}, process exiting: ${location}`\n )\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n this.sendMessage({ ready: true })\n }\n\n async finalize(): Promise<void> {\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions,\n 'an AfterAll'\n )\n this.exit(0)\n }\n\n async receiveMessage(message: IWorkerCommand): Promise<void> {\n if (doesHaveValue(message.initialize)) {\n await this.initialize(message.initialize)\n } else if (message.finalize) {\n await this.finalize()\n } else if (doesHaveValue(message.run)) {\n await this.runTestCase(message.run)\n }\n }\n\n async runTestCase({\n gherkinDocument,\n pickle,\n testCase,\n elapsed,\n retries,\n skip,\n }: IWorkerCommandRun): Promise<void> {\n const stopwatch = new RealTestRunStopwatch()\n stopwatch.from(duration(elapsed))\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n filterStackTraces: this.filterStacktraces,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.worldParameters,\n })\n await testCaseRunner.run()\n this.sendMessage({ ready: true })\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  import TestRunHookDefinition from '../models/test_run_hook_definition';
2
- export declare type RunsTestRunHooks = (definitions: TestRunHookDefinition[], name: string) => Promise<void>;
2
+ export type RunsTestRunHooks = (definitions: TestRunHookDefinition[], name: string) => Promise<void>;
3
3
  export declare const makeRunTestRunHooks: (dryRun: boolean, defaultTimeout: number, errorMessage: (name: string, location: string) => string) => RunsTestRunHooks;
@@ -5,8 +5,8 @@ import TestRunHookDefinition from '../models/test_run_hook_definition';
5
5
  import StepDefinition from '../models/step_definition';
6
6
  import { ParameterTypeRegistry } from '@cucumber/cucumber-expressions';
7
7
  import { IWorld } from './world';
8
- export declare type DefineStepPattern = string | RegExp;
9
- export declare type ParallelAssignmentValidator = (pickle: messages.Pickle, runningPickles: messages.Pickle[]) => boolean;
8
+ export type DefineStepPattern = string | RegExp;
9
+ export type ParallelAssignmentValidator = (pickle: messages.Pickle, runningPickles: messages.Pickle[]) => boolean;
10
10
  export interface ITestCaseHookParameter {
11
11
  gherkinDocument: messages.GherkinDocument;
12
12
  pickle: messages.Pickle;
@@ -22,9 +22,9 @@ export interface ITestStepHookParameter {
22
22
  testCaseStartedId: string;
23
23
  testStepId: string;
24
24
  }
25
- export declare type TestCaseHookFunction<WorldType> = (this: WorldType, arg: ITestCaseHookParameter) => any | Promise<any>;
26
- export declare type TestStepHookFunction<WorldType> = (this: WorldType, arg: ITestStepHookParameter) => any | Promise<any>;
27
- export declare type TestStepFunction<WorldType> = (this: WorldType, ...args: any[]) => any | Promise<any>;
25
+ export type TestCaseHookFunction<WorldType> = (this: WorldType, arg: ITestCaseHookParameter) => any | Promise<any>;
26
+ export type TestStepHookFunction<WorldType> = (this: WorldType, arg: ITestStepHookParameter) => any | Promise<any>;
27
+ export type TestStepFunction<WorldType> = (this: WorldType, ...args: any[]) => any | Promise<any>;
28
28
  export interface IDefineStepOptions {
29
29
  timeout?: number;
30
30
  wrapperOptions?: any;
@@ -48,7 +48,7 @@ export interface IParameterTypeDefinition<T> {
48
48
  useForSnippets?: boolean;
49
49
  preferForRegexpMatch?: boolean;
50
50
  }
51
- export declare type IDefineStep = (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
51
+ export type IDefineStep = (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
52
52
  export interface IDefineSupportCodeMethods {
53
53
  defineParameterType: (options: IParameterTypeDefinition<any>) => void;
54
54
  defineStep: IDefineStep;
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "8.8.0";
1
+ export declare const version = "8.9.1";
package/lib/version.js CHANGED
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = '8.8.0';
5
+ exports.version = '8.9.1';
6
6
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '8.8.0'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '8.9.1'\n"]}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "gherkin",
9
9
  "tests"
10
10
  ],
11
- "version": "8.8.0",
11
+ "version": "8.9.1",
12
12
  "homepage": "https://github.com/cucumber/cucumber-js",
13
13
  "author": "Julien Biezemans <jb@jbpros.com>",
14
14
  "contributors": [
@@ -197,11 +197,11 @@
197
197
  },
198
198
  "dependencies": {
199
199
  "@cucumber/ci-environment": "9.1.0",
200
- "@cucumber/cucumber-expressions": "16.0.0",
201
- "@cucumber/gherkin": "24.1.0",
200
+ "@cucumber/cucumber-expressions": "16.1.0",
201
+ "@cucumber/gherkin": "25.0.2",
202
202
  "@cucumber/gherkin-streams": "5.0.1",
203
- "@cucumber/gherkin-utils": "8.0.1",
204
- "@cucumber/html-formatter": "20.1.0",
203
+ "@cucumber/gherkin-utils": "8.0.2",
204
+ "@cucumber/html-formatter": "20.2.0",
205
205
  "@cucumber/message-streams": "4.0.1",
206
206
  "@cucumber/messages": "20.0.0",
207
207
  "@cucumber/tag-expressions": "4.1.0",
@@ -233,15 +233,17 @@
233
233
  "tmp": "^0.2.1",
234
234
  "util-arity": "^1.1.0",
235
235
  "verror": "^1.10.0",
236
+ "xmlbuilder": "^15.1.1",
236
237
  "yup": "^0.32.11"
237
238
  },
238
239
  "devDependencies": {
239
240
  "@cucumber/compatibility-kit": "11.0.1",
240
- "@cucumber/query": "12.0.0",
241
- "@microsoft/api-documenter": "7.19.23",
242
- "@microsoft/api-extractor": "7.33.5",
243
- "@sinonjs/fake-timers": "9.1.2",
244
- "@types/chai": "4.3.3",
241
+ "@cucumber/query": "12.0.1",
242
+ "@microsoft/api-documenter": "7.19.25",
243
+ "@microsoft/api-extractor": "7.33.6",
244
+ "@sinonjs/fake-timers": "10.0.0",
245
+ "@types/chai": "4.3.4",
246
+ "@types/chai-xml": "^0.3.2",
245
247
  "@types/debug": "4.1.7",
246
248
  "@types/dirty-chai": "2.0.2",
247
249
  "@types/express": "4.17.14",
@@ -250,25 +252,26 @@
250
252
  "@types/has-ansi": "5.0.0",
251
253
  "@types/lodash.merge": "4.6.7",
252
254
  "@types/lodash.mergewith": "4.6.7",
253
- "@types/mocha": "10.0.0",
254
- "@types/mustache": "4.2.1",
255
+ "@types/mocha": "10.0.1",
256
+ "@types/mustache": "4.2.2",
255
257
  "@types/mz": "2.7.4",
256
- "@types/node": "18.11.9",
258
+ "@types/node": "18.11.10",
257
259
  "@types/progress": "2.0.5",
258
260
  "@types/semver": "7.3.13",
259
- "@types/sinon-chai": "3.2.8",
261
+ "@types/sinon-chai": "3.2.9",
260
262
  "@types/sinonjs__fake-timers": "8.1.2",
261
263
  "@types/stream-buffers": "3.0.4",
262
264
  "@types/tmp": "0.2.3",
263
265
  "@types/verror": "1.10.6",
264
- "@typescript-eslint/eslint-plugin": "5.42.0",
265
- "@typescript-eslint/parser": "5.42.0",
266
- "chai": "4.3.6",
266
+ "@typescript-eslint/eslint-plugin": "5.45.0",
267
+ "@typescript-eslint/parser": "5.45.0",
268
+ "chai": "4.3.7",
267
269
  "chai-exclude": "2.1.0",
270
+ "chai-xml": "^0.4.0",
268
271
  "coffeescript": "2.7.0",
269
272
  "dependency-lint": "7.1.0",
270
273
  "dirty-chai": "2.0.1",
271
- "eslint": "8.26.0",
274
+ "eslint": "8.28.0",
272
275
  "eslint-config-prettier": "8.5.0",
273
276
  "eslint-plugin-import": "2.26.0",
274
277
  "eslint-plugin-node": "11.1.0",
@@ -280,16 +283,16 @@
280
283
  "mocha": "10.1.0",
281
284
  "mustache": "4.2.0",
282
285
  "nyc": "15.1.0",
283
- "prettier": "2.7.1",
286
+ "prettier": "2.8.0",
284
287
  "reindent-template-literals": "1.1.0",
285
288
  "shx": "0.3.4",
286
- "sinon": "14.0.1",
289
+ "sinon": "15.0.0",
287
290
  "sinon-chai": "3.7.0",
288
291
  "stream-buffers": "3.0.2",
289
292
  "stream-to-string": "1.2.0",
290
293
  "ts-node": "10.9.1",
291
- "tsd": "0.24.1",
292
- "typescript": "4.8.4"
294
+ "tsd": "0.25.0",
295
+ "typescript": "4.9.3"
293
296
  },
294
297
  "overrides": {
295
298
  "ansi-regex": "^5.0.1"