@cucumber/cucumber 8.7.0 → 8.9.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.
Files changed (33) hide show
  1. package/lib/filter_stack_trace.d.ts +3 -0
  2. package/lib/filter_stack_trace.js +38 -0
  3. package/lib/filter_stack_trace.js.map +1 -0
  4. package/lib/formatter/helpers/formatters.js +2 -0
  5. package/lib/formatter/helpers/formatters.js.map +1 -1
  6. package/lib/formatter/junit_formatter.d.ts +16 -0
  7. package/lib/formatter/junit_formatter.js +177 -0
  8. package/lib/formatter/junit_formatter.js.map +1 -0
  9. package/lib/runtime/format_error.d.ts +1 -0
  10. package/lib/runtime/format_error.js +29 -0
  11. package/lib/runtime/format_error.js.map +1 -0
  12. package/lib/runtime/index.d.ts +0 -1
  13. package/lib/runtime/index.js +1 -8
  14. package/lib/runtime/index.js.map +1 -1
  15. package/lib/runtime/parallel/worker.d.ts +0 -1
  16. package/lib/runtime/parallel/worker.js +6 -11
  17. package/lib/runtime/parallel/worker.js.map +1 -1
  18. package/lib/runtime/step_runner.d.ts +2 -1
  19. package/lib/runtime/step_runner.js +3 -3
  20. package/lib/runtime/step_runner.js.map +1 -1
  21. package/lib/runtime/test_case_runner.d.ts +4 -1
  22. package/lib/runtime/test_case_runner.js +53 -47
  23. package/lib/runtime/test_case_runner.js.map +1 -1
  24. package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +1 -1
  25. package/lib/support_code_library_builder/get_definition_line_and_uri.js +5 -6
  26. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -1
  27. package/lib/version.d.ts +1 -1
  28. package/lib/version.js +1 -1
  29. package/lib/version.js.map +1 -1
  30. package/package.json +22 -19
  31. package/lib/stack_trace_filter.d.ts +0 -11
  32. package/lib/stack_trace_filter.js +0 -46
  33. package/lib/stack_trace_filter.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ import { StackFrame } from 'error-stack-parser';
2
+ export declare function isFileNameInCucumber(fileName: string): boolean;
3
+ export declare function filterStackTrace(frames: StackFrame[]): StackFrame[];
@@ -0,0 +1,38 @@
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.filterStackTrace = exports.isFileNameInCucumber = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const value_checker_1 = require("./value_checker");
9
+ const projectRootPath = path_1.default.join(__dirname, '..');
10
+ const projectChildDirs = ['src', 'lib', 'node_modules'];
11
+ function isFileNameInCucumber(fileName) {
12
+ return projectChildDirs.some((dir) => fileName.startsWith(path_1.default.join(projectRootPath, dir)));
13
+ }
14
+ exports.isFileNameInCucumber = isFileNameInCucumber;
15
+ function filterStackTrace(frames) {
16
+ if (isErrorInCucumber(frames)) {
17
+ return frames;
18
+ }
19
+ const index = frames.findIndex((x) => isFrameInCucumber(x));
20
+ if (index === -1) {
21
+ return frames;
22
+ }
23
+ return frames.slice(0, index);
24
+ }
25
+ exports.filterStackTrace = filterStackTrace;
26
+ function isErrorInCucumber(frames) {
27
+ const filteredFrames = frames.filter((x) => !isFrameInNode(x));
28
+ return filteredFrames.length > 0 && isFrameInCucumber(filteredFrames[0]);
29
+ }
30
+ function isFrameInCucumber(frame) {
31
+ const fileName = (0, value_checker_1.valueOrDefault)(frame.getFileName(), '');
32
+ return isFileNameInCucumber(fileName);
33
+ }
34
+ function isFrameInNode(frame) {
35
+ const fileName = (0, value_checker_1.valueOrDefault)(frame.getFileName(), '');
36
+ return !fileName.includes(path_1.default.sep);
37
+ }
38
+ //# sourceMappingURL=filter_stack_trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter_stack_trace.js","sourceRoot":"","sources":["../src/filter_stack_trace.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,mDAAgD;AAGhD,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS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AAK,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAA;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAI,CAAC,GAAG,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import path from 'path'\nimport { valueOrDefault } from './value_checker'\nimport { StackFrame } from 'error-stack-parser'\n\nconst projectRootPath = path.join(__dirname, '..')\nconst projectChildDirs = ['src', 'lib', 'node_modules']\n\nexport function isFileNameInCucumber(fileName: string): boolean {\n return projectChildDirs.some((dir) =>\n fileName.startsWith(path.join(projectRootPath, dir))\n )\n}\n\nexport function filterStackTrace(frames: StackFrame[]): StackFrame[] {\n if (isErrorInCucumber(frames)) {\n return frames\n }\n const index = frames.findIndex((x) => isFrameInCucumber(x))\n if (index === -1) {\n return frames\n }\n return frames.slice(0, index)\n}\n\nfunction isErrorInCucumber(frames: StackFrame[]): boolean {\n const filteredFrames = frames.filter((x) => !isFrameInNode(x))\n return filteredFrames.length > 0 && isFrameInCucumber(filteredFrames[0])\n}\n\nfunction isFrameInCucumber(frame: StackFrame): boolean {\n const fileName = valueOrDefault(frame.getFileName(), '')\n return isFileNameInCucumber(fileName)\n}\n\nfunction isFrameInNode(frame: StackFrame): boolean {\n const fileName = valueOrDefault(frame.getFileName(), '')\n return !fileName.includes(path.sep)\n}\n"]}
@@ -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"]}
@@ -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,kBAAkB;aA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I,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"]}
@@ -0,0 +1 @@
1
+ export declare function formatError(error: Error, filterStackTraces: boolean): string;
@@ -0,0 +1,29 @@
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.formatError = void 0;
7
+ const assertion_error_formatter_1 = require("assertion-error-formatter");
8
+ const error_stack_parser_1 = __importDefault(require("error-stack-parser"));
9
+ const filter_stack_trace_1 = require("../filter_stack_trace");
10
+ function formatError(error, filterStackTraces) {
11
+ let filteredStack;
12
+ if (filterStackTraces) {
13
+ try {
14
+ filteredStack = (0, filter_stack_trace_1.filterStackTrace)(error_stack_parser_1.default.parse(error))
15
+ .map((f) => f.source)
16
+ .join('\n');
17
+ }
18
+ catch (_a) {
19
+ // if we weren't able to parse and filter, we'll settle for the original
20
+ }
21
+ }
22
+ return (0, assertion_error_formatter_1.format)(error, {
23
+ colorFns: {
24
+ errorStack: (stack) => filteredStack ? `\n${filteredStack}` : stack,
25
+ },
26
+ });
27
+ }
28
+ exports.formatError = formatError;
29
+ //# sourceMappingURL=format_error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format_error.js","sourceRoot":"","sources":["../../src/runtime/format_error.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAkD;AAClD,4EAAiD;AACjD,8DAAwD;AAExD,SAAgB,WAAW,CAAC,KAAY,EAAE,iBAA0B;IAClE,IAAI,aAAqB,CAAA;IACzB,IAAI,iBAAiB,EAAE;QACrB,IAAI;YACF,aAAa,GAAG,IAAA,qCAAgB,EAAC,4BAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBAC5D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;iBACpB,IAAI,CAAC,IAAI,CAAC,CAAA;SACd;QAAC,WAAM;YACN,wEAAwE;SACzE;KACF;IACD,OAAO,IAAA,kCAAM,EAAC,KAAK,EAAE;QACnB,QAAQ,EAAE;YACR,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAC5B,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE,CAAC,CAAC,CAAC,KAAK;SAC/C;KACF,CAAC,CAAA;AACJ,CAAC;AAjBD,kCAiBC","sourcesContent":["import { format } from 'assertion-error-formatter'\nimport errorStackParser from 'error-stack-parser'\nimport { filterStackTrace } from '../filter_stack_trace'\n\nexport function formatError(error: Error, filterStackTraces: boolean): string {\n let filteredStack: string\n if (filterStackTraces) {\n try {\n filteredStack = filterStackTrace(errorStackParser.parse(error))\n .map((f) => f.source)\n .join('\\n')\n } catch {\n // if we weren't able to parse and filter, we'll settle for the original\n }\n }\n return format(error, {\n colorFns: {\n errorStack: (stack: string) =>\n filteredStack ? `\\n${filteredStack}` : stack,\n },\n })\n}\n"]}
@@ -31,7 +31,6 @@ export default class Runtime implements IRuntime {
31
31
  private readonly newId;
32
32
  private readonly options;
33
33
  private readonly pickleIds;
34
- private readonly stackTraceFilter;
35
34
  private readonly supportCodeLibrary;
36
35
  private success;
37
36
  private runTestRunHooks;
@@ -3,7 +3,6 @@ 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
- const stack_trace_filter_1 = __importDefault(require("../stack_trace_filter"));
7
6
  const assemble_test_cases_1 = require("./assemble_test_cases");
8
7
  const helpers_1 = require("./helpers");
9
8
  const run_test_run_hooks_1 = require("./run_test_run_hooks");
@@ -17,7 +16,6 @@ class Runtime {
17
16
  this.newId = newId;
18
17
  this.options = options;
19
18
  this.pickleIds = pickleIds;
20
- this.stackTraceFilter = new stack_trace_filter_1.default();
21
19
  this.supportCodeLibrary = supportCodeLibrary;
22
20
  this.success = true;
23
21
  this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(this.options.dryRun, this.supportCodeLibrary.defaultTimeout, (name, location) => `${name} hook errored, process exiting: ${location}`);
@@ -35,6 +33,7 @@ class Runtime {
35
33
  testCase,
36
34
  retries,
37
35
  skip,
36
+ filterStackTraces: this.options.filterStacktraces,
38
37
  supportCodeLibrary: this.supportCodeLibrary,
39
38
  worldParameters: this.options.worldParameters,
40
39
  });
@@ -44,9 +43,6 @@ class Runtime {
44
43
  }
45
44
  }
46
45
  async start() {
47
- if (this.options.filterStacktraces) {
48
- this.stackTraceFilter.filter();
49
- }
50
46
  const testRunStarted = {
51
47
  testRunStarted: {
52
48
  timestamp: this.stopwatch.timestamp(),
@@ -73,9 +69,6 @@ class Runtime {
73
69
  },
74
70
  };
75
71
  this.eventBroadcaster.emit('envelope', testRunFinished);
76
- if (this.options.filterStacktraces) {
77
- this.stackTraceFilter.unfilter();
78
- }
79
72
  return this.success;
80
73
  }
81
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;AAIA,+EAAoD;AAEpD,+DAAyD;AACzD,uCAAgE;AAChE,6DAA4E;AAC5E,2CAAqE;AACrE,0EAA+C;AAyB/C,MAAqB,OAAO;IAY1B,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,GACC;QACnB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,gCAAoB,EAAE,CAAA;QAC3C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OA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AAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;QACrB,MAAM,eAAe,GAAsB;YACzC,eAAe,EAAE;gBACf,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;gBACrC,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAA;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAA;QACvD,IAAI,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE;YAClC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAA;SACjC;QACD,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAxGD,0BAwGC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport StackTraceFilter from '../stack_trace_filter'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { assembleTestCases } from './assemble_test_cases'\nimport { retriesForPickle, shouldCauseFailure } from './helpers'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from './run_test_run_hooks'\nimport { ITestRunStopwatch, RealTestRunStopwatch } from './stopwatch'\nimport TestCaseRunner from './test_case_runner'\n\nexport interface IRuntime {\n start: () => Promise<boolean>\n}\n\nexport interface INewRuntimeOptions {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n newId: IdGenerator.NewId\n options: IRuntimeOptions\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IRuntimeOptions {\n dryRun: boolean\n failFast: boolean\n filterStacktraces: boolean\n retry: number\n retryTagFilter: string\n strict: boolean\n worldParameters: any\n}\n\nexport default class Runtime implements IRuntime {\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: ITestRunStopwatch\n private readonly newId: IdGenerator.NewId\n private readonly options: IRuntimeOptions\n private readonly pickleIds: string[]\n private readonly stackTraceFilter: StackTraceFilter\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private success: boolean\n private runTestRunHooks: RunsTestRunHooks\n\n constructor({\n eventBroadcaster,\n eventDataCollector,\n newId,\n options,\n pickleIds,\n supportCodeLibrary,\n }: INewRuntimeOptions) {\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = new RealTestRunStopwatch()\n this.newId = newId\n this.options = options\n this.pickleIds = pickleIds\n this.stackTraceFilter = new StackTraceFilter()\n this.supportCodeLibrary = supportCodeLibrary\n this.success = true\n this.runTestRunHooks = makeRunTestRunHooks(\n this.options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n (name, location) => `${name} hook errored, process exiting: ${location}`\n )\n }\n\n async runTestCase(\n pickleId: string,\n testCase: messages.TestCase\n ): Promise<void> {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch: this.stopwatch,\n gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.options.worldParameters,\n })\n const status = await testCaseRunner.run()\n if (shouldCauseFailure(status, this.options)) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n if (this.options.filterStacktraces) {\n this.stackTraceFilter.filter()\n }\n const testRunStarted: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testRunStarted)\n this.stopwatch.start()\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n const assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n for (const pickleId of this.pickleIds) {\n await this.runTestCase(pickleId, assembledTestCases[pickleId])\n }\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(),\n 'an AfterAll'\n )\n this.stopwatch.stop()\n const testRunFinished: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success: this.success,\n },\n }\n this.eventBroadcaster.emit('envelope', testRunFinished)\n if (this.options.filterStacktraces) {\n this.stackTraceFilter.unfilter()\n }\n return this.success\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;AAKA,+DAAyD;AACzD,uCAAgE;AAChE,6DAA4E;AAC5E,2CAAqE;AACrE,0EAA+C;AAyB/C,MAAqB,OAAO;IAW1B,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,EACL,OAAO,EACP,SAAS,EACT,kBAAkB,GACC;QACnB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAI,gCAAoB,EAAE,CAAA;QAC3C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,eAAe,GAAG,IAAA,wCAAmB,EACxC,IAAI,CAAC,OAAO,CAAC,MAAM,EACnB,IAAI,CAAC,kBAAkB,CAAC,cAAc,EACtC,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,GAAG,IAAI,mCAAmC,QAAQ,EAAE,C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QACtD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QACtB,MAAM,IAAI,CAAC,eAAe,CACxB,IAAI,CAAC,kBAAkB,CAAC,4BAA4B,EACpD,aAAa,CACd,CAAA;QACD,MAAM,kBAAkB,GAAG,MAAM,IAAA,uCAAiB,EAAC;YACjD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACvC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAC5C;YACD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC5C,CAAC,CAAA;QACF,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;YACrC,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAA;SAC/D;QACD,MAAM,IAAI,CAAC,eAAe,CACxB,IAAI,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EACtE,aAAa,CACd,CAAA;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;QACrB,MAAM,eAAe,GAAsB;YACzC,eAAe,EAAE;gBACf,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;gBACrC,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAA;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAA;QACvD,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAjGD,0BAiGC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { assembleTestCases } from './assemble_test_cases'\nimport { retriesForPickle, shouldCauseFailure } from './helpers'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from './run_test_run_hooks'\nimport { ITestRunStopwatch, RealTestRunStopwatch } from './stopwatch'\nimport TestCaseRunner from './test_case_runner'\n\nexport interface IRuntime {\n start: () => Promise<boolean>\n}\n\nexport interface INewRuntimeOptions {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n newId: IdGenerator.NewId\n options: IRuntimeOptions\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IRuntimeOptions {\n dryRun: boolean\n failFast: boolean\n filterStacktraces: boolean\n retry: number\n retryTagFilter: string\n strict: boolean\n worldParameters: any\n}\n\nexport default class Runtime implements IRuntime {\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: ITestRunStopwatch\n private readonly newId: IdGenerator.NewId\n private readonly options: IRuntimeOptions\n private readonly pickleIds: string[]\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private success: boolean\n private runTestRunHooks: RunsTestRunHooks\n\n constructor({\n eventBroadcaster,\n eventDataCollector,\n newId,\n options,\n pickleIds,\n supportCodeLibrary,\n }: INewRuntimeOptions) {\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = new RealTestRunStopwatch()\n this.newId = newId\n this.options = options\n this.pickleIds = pickleIds\n this.supportCodeLibrary = supportCodeLibrary\n this.success = true\n this.runTestRunHooks = makeRunTestRunHooks(\n this.options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n (name, location) => `${name} hook errored, process exiting: ${location}`\n )\n }\n\n async runTestCase(\n pickleId: string,\n testCase: messages.TestCase\n ): Promise<void> {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch: this.stopwatch,\n gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n filterStackTraces: this.options.filterStacktraces,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.options.worldParameters,\n })\n const status = await testCaseRunner.run()\n if (shouldCauseFailure(status, this.options)) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n const testRunStarted: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testRunStarted)\n this.stopwatch.start()\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n const assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n for (const pickleId of this.pickleIds) {\n await this.runTestCase(pickleId, assembledTestCases[pickleId])\n }\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(),\n 'an AfterAll'\n )\n this.stopwatch.stop()\n const testRunFinished: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success: this.success,\n },\n }\n this.eventBroadcaster.emit('envelope', testRunFinished)\n return this.success\n }\n}\n"]}
@@ -9,7 +9,6 @@ export default class Worker {
9
9
  private filterStacktraces;
10
10
  private readonly newId;
11
11
  private readonly sendMessage;
12
- private readonly stackTraceFilter;
13
12
  private supportCodeLibrary;
14
13
  private worldParameters;
15
14
  private runTestRunHooks;
@@ -7,7 +7,6 @@ const messages_1 = require("@cucumber/messages");
7
7
  const durations_1 = require("durations");
8
8
  const events_1 = require("events");
9
9
  const url_1 = require("url");
10
- const stack_trace_filter_1 = __importDefault(require("../../stack_trace_filter"));
11
10
  const support_code_library_builder_1 = __importDefault(require("../../support_code_library_builder"));
12
11
  const value_checker_1 = require("../../value_checker");
13
12
  const run_test_run_hooks_1 = require("../run_test_run_hooks");
@@ -24,11 +23,12 @@ class Worker {
24
23
  this.exit = exit;
25
24
  this.sendMessage = sendMessage;
26
25
  this.eventBroadcaster = new events_1.EventEmitter();
27
- this.stackTraceFilter = new stack_trace_filter_1.default();
28
26
  this.eventBroadcaster.on('envelope', (envelope) => {
29
- this.sendMessage({
30
- jsonEnvelope: JSON.stringify(envelope),
31
- });
27
+ // assign `workerId` property only for the `testCaseStarted` message
28
+ if (envelope.testCaseStarted) {
29
+ envelope.testCaseStarted.workerId = this.id;
30
+ }
31
+ this.sendMessage({ jsonEnvelope: JSON.stringify(envelope) });
32
32
  });
33
33
  }
34
34
  async initialize({ filterStacktraces, requireModules, requirePaths, importPaths, supportCodeIds, options, }) {
@@ -41,18 +41,12 @@ class Worker {
41
41
  this.supportCodeLibrary = support_code_library_builder_1.default.finalize(supportCodeIds);
42
42
  this.worldParameters = options.worldParameters;
43
43
  this.filterStacktraces = filterStacktraces;
44
- if (this.filterStacktraces) {
45
- this.stackTraceFilter.filter();
46
- }
47
44
  this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(options.dryRun, this.supportCodeLibrary.defaultTimeout, (name, location) => `${name} hook errored on worker ${this.id}, process exiting: ${location}`);
48
45
  await this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');
49
46
  this.sendMessage({ ready: true });
50
47
  }
51
48
  async finalize() {
52
49
  await this.runTestRunHooks(this.supportCodeLibrary.afterTestRunHookDefinitions, 'an AfterAll');
53
- if (this.filterStacktraces) {
54
- this.stackTraceFilter.unfilter();
55
- }
56
50
  this.exit(0);
57
51
  }
58
52
  async receiveMessage(message) {
@@ -78,6 +72,7 @@ class Worker {
78
72
  testCase,
79
73
  retries,
80
74
  skip,
75
+ filterStackTraces: this.filterStacktraces,
81
76
  supportCodeLibrary: this.supportCodeLibrary,
82
77
  worldParameters: this.worldParameters,
83
78
  });
@@ -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,kFAAuD;AACvD,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;IAczB,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,GAAG,IAAI,4BAAgB,EAAE,CAAA;QAC9C,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACnE,IAAI,CAAC,WAAW,CAAC;gBACf,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;aACvC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,EACf,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,WAAW,EACX,cAAc,EACd,OAAO,GACkB;QACzB,sCAAyB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAA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D,IAAI,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,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;AAvHD,yBAuHC","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 StackTraceFilter from '../../stack_trace_filter'\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 readonly stackTraceFilter: StackTraceFilter\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.stackTraceFilter = new StackTraceFilter()\n this.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n this.sendMessage({\n jsonEnvelope: JSON.stringify(envelope),\n })\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 if (this.filterStacktraces) {\n this.stackTraceFilter.filter()\n }\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 if (this.filterStacktraces) {\n this.stackTraceFilter.unfilter()\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 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,E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ACH,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;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"]}
@@ -3,12 +3,13 @@ import { ITestCaseHookParameter } from '../support_code_library_builder/types';
3
3
  import { IDefinition } from '../models/definition';
4
4
  export interface IRunOptions {
5
5
  defaultTimeout: number;
6
+ filterStackTraces: boolean;
6
7
  hookParameter: ITestCaseHookParameter;
7
8
  step: messages.PickleStep;
8
9
  stepDefinition: IDefinition;
9
10
  world: any;
10
11
  }
11
- export declare function run({ defaultTimeout, hookParameter, step, stepDefinition, world, }: IRunOptions): Promise<messages.TestStepResult>;
12
+ export declare function run({ defaultTimeout, filterStackTraces, hookParameter, step, stepDefinition, world, }: IRunOptions): Promise<messages.TestStepResult>;
12
13
  declare const _default: {
13
14
  run: typeof run;
14
15
  };
@@ -30,10 +30,10 @@ exports.run = void 0;
30
30
  const time_1 = __importDefault(require("../time"));
31
31
  const user_code_runner_1 = __importDefault(require("../user_code_runner"));
32
32
  const messages = __importStar(require("@cucumber/messages"));
33
- const assertion_error_formatter_1 = require("assertion-error-formatter");
34
33
  const value_checker_1 = require("../value_checker");
34
+ const format_error_1 = require("./format_error");
35
35
  const { beginTiming, endTiming } = time_1.default;
36
- async function run({ defaultTimeout, hookParameter, step, stepDefinition, world, }) {
36
+ async function run({ defaultTimeout, filterStackTraces, hookParameter, step, stepDefinition, world, }) {
37
37
  beginTiming();
38
38
  let error, result, invocationData;
39
39
  try {
@@ -72,7 +72,7 @@ async function run({ defaultTimeout, hookParameter, step, stepDefinition, world,
72
72
  status = messages.TestStepResultStatus.PENDING;
73
73
  }
74
74
  else if ((0, value_checker_1.doesHaveValue)(error)) {
75
- message = (0, assertion_error_formatter_1.format)(error);
75
+ message = (0, format_error_1.formatError)(error, filterStackTraces);
76
76
  status = messages.TestStepResultStatus.FAILED;
77
77
  }
78
78
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"step_runner.js","sourceRoot":"","sources":["../../src/runtime/step_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA0B;AAC1B,2EAAgD;AAChD,6DAA8C;AAC9C,yEAAkD;AAGlD,oDAIyB;AAEzB,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,cAAI,CAAA;AAUhC,KAAK,UAAU,GAAG,CAAC,EACxB,cAAc,EACd,aAAa,EACb,IAAI,EACJ,cAAc,EACd,KAAK,GACO;IACZ,WAAW,EAAE,CAAA;IACb,IAAI,KAAU,EAAE,MAAW,EAAE,cAA0C,CAAA;IAEvE,IAAI;QACF,cAAc,GAAG,MAAM,cAAc,CAAC,uBAAuB,CAAC;YAC5D,aAAa;YACb,IAAI;YACJ,KAAK;SACN,CAAC,CAAA;KACH;IAAC,OAAO,GAAG,EAAE;QACZ,KAAK,GAAG,GAAG,CAAA;KACZ;IAED,IAAI,IAAA,gCAAgB,EAAC,KAAK,CAAC,EAAE;QAC3B,MAAM,qBAAqB,GAAG,IAAA,8BAAc,EAC1C,cAAc,CAAC,OAAO,CAAC,OAAO,EAC9B,cAAc,CACf,CAAA;QAED,IAAI,cAAc,CAAC,gBAAgB,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YACxE,MAAM,IAAI,GAAG,MAAM,0BAAc,CAAC,GAAG,CAAC;gBACpC,SAAS,EAAE,cAAc,CAAC,UAAU;gBACpC,EAAE,EAAE,cAAc,CAAC,IAAI;gBACvB,OAAO,EAAE,KAAK;gBACd,qBAAqB;aACtB,CAAC,CAAA;YACF,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;YAClB,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;SACrB;aAAM;YACL,KAAK,GAAG,cAAc,CAAC,2BAA2B,EAAE,CAAA;SACrD;KACF;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,SAAS,EAAE,CAAC,CAAA;IAC5E,IAAI,MAAqC,CAAA;IACzC,IAAI,OAAe,CAAA;IACnB,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAA;KAC/C;SAAM,IAAI,MAAM,KAAK,SAAS,EAAE;QAC/B,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAA;KAC/C;SAAM,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,EAAE;QAC/B,OAAO,GAAG,IAAA,kCAAM,EAAC,KAAK,CAAC,CAAA;QACvB,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAA;KAC9C;SAAM;QACL,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAA;KAC9C;IAED,OAAO;QACL,QAAQ;QACR,MAAM;QACN,OAAO;KACR,CAAA;AACH,CAAC;AA3DD,kBA2DC;AAED,kBAAe,EAAE,GAAG,EAAE,CAAA","sourcesContent":["import Time from '../time'\nimport UserCodeRunner from '../user_code_runner'\nimport * as messages from '@cucumber/messages'\nimport { format } from 'assertion-error-formatter'\nimport { ITestCaseHookParameter } from '../support_code_library_builder/types'\nimport { IDefinition, IGetInvocationDataResponse } from '../models/definition'\nimport {\n doesHaveValue,\n doesNotHaveValue,\n valueOrDefault,\n} from '../value_checker'\n\nconst { beginTiming, endTiming } = Time\n\nexport interface IRunOptions {\n defaultTimeout: number\n hookParameter: ITestCaseHookParameter\n step: messages.PickleStep\n stepDefinition: IDefinition\n world: any\n}\n\nexport async function run({\n defaultTimeout,\n hookParameter,\n step,\n stepDefinition,\n world,\n}: IRunOptions): Promise<messages.TestStepResult> {\n beginTiming()\n let error: any, result: any, invocationData: IGetInvocationDataResponse\n\n try {\n invocationData = await stepDefinition.getInvocationParameters({\n hookParameter,\n step,\n world,\n })\n } catch (err) {\n error = err\n }\n\n if (doesNotHaveValue(error)) {\n const timeoutInMilliseconds = valueOrDefault(\n stepDefinition.options.timeout,\n defaultTimeout\n )\n\n if (invocationData.validCodeLengths.includes(stepDefinition.code.length)) {\n const data = await UserCodeRunner.run({\n argsArray: invocationData.parameters,\n fn: stepDefinition.code,\n thisArg: world,\n timeoutInMilliseconds,\n })\n error = data.error\n result = data.result\n } else {\n error = invocationData.getInvalidCodeLengthMessage()\n }\n }\n\n const duration = messages.TimeConversion.millisecondsToDuration(endTiming())\n let status: messages.TestStepResultStatus\n let message: string\n if (result === 'skipped') {\n status = messages.TestStepResultStatus.SKIPPED\n } else if (result === 'pending') {\n status = messages.TestStepResultStatus.PENDING\n } else if (doesHaveValue(error)) {\n message = format(error)\n status = messages.TestStepResultStatus.FAILED\n } else {\n status = messages.TestStepResultStatus.PASSED\n }\n\n return {\n duration,\n status,\n message,\n }\n}\n\nexport default { run }\n"]}
1
+ {"version":3,"file":"step_runner.js","sourceRoot":"","sources":["../../src/runtime/step_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA0B;AAC1B,2EAAgD;AAChD,6DAA8C;AAG9C,oDAIyB;AACzB,iDAA4C;AAE5C,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,cAAI,CAAA;AAWhC,KAAK,UAAU,GAAG,CAAC,EACxB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,IAAI,EACJ,cAAc,EACd,KA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,EAAE;QAC/B,OAAO,GAAG,IAAA,0BAAW,EAAC,KAAK,EAAE,iBAAiB,CAAC,CAAA;QAC/C,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAA;KAC9C;SAAM;QACL,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAA;KAC9C;IAED,OAAO;QACL,QAAQ;QACR,MAAM;QACN,OAAO;KACR,CAAA;AACH,CAAC;AA5DD,kBA4DC;AAED,kBAAe,EAAE,GAAG,EAAE,CAAA","sourcesContent":["import Time from '../time'\nimport UserCodeRunner from '../user_code_runner'\nimport * as messages from '@cucumber/messages'\nimport { ITestCaseHookParameter } from '../support_code_library_builder/types'\nimport { IDefinition, IGetInvocationDataResponse } from '../models/definition'\nimport {\n doesHaveValue,\n doesNotHaveValue,\n valueOrDefault,\n} from '../value_checker'\nimport { formatError } from './format_error'\n\nconst { beginTiming, endTiming } = Time\n\nexport interface IRunOptions {\n defaultTimeout: number\n filterStackTraces: boolean\n hookParameter: ITestCaseHookParameter\n step: messages.PickleStep\n stepDefinition: IDefinition\n world: any\n}\n\nexport async function run({\n defaultTimeout,\n filterStackTraces,\n hookParameter,\n step,\n stepDefinition,\n world,\n}: IRunOptions): Promise<messages.TestStepResult> {\n beginTiming()\n let error: any, result: any, invocationData: IGetInvocationDataResponse\n\n try {\n invocationData = await stepDefinition.getInvocationParameters({\n hookParameter,\n step,\n world,\n })\n } catch (err) {\n error = err\n }\n\n if (doesNotHaveValue(error)) {\n const timeoutInMilliseconds = valueOrDefault(\n stepDefinition.options.timeout,\n defaultTimeout\n )\n\n if (invocationData.validCodeLengths.includes(stepDefinition.code.length)) {\n const data = await UserCodeRunner.run({\n argsArray: invocationData.parameters,\n fn: stepDefinition.code,\n thisArg: world,\n timeoutInMilliseconds,\n })\n error = data.error\n result = data.result\n } else {\n error = invocationData.getInvalidCodeLengthMessage()\n }\n }\n\n const duration = messages.TimeConversion.millisecondsToDuration(endTiming())\n let status: messages.TestStepResultStatus\n let message: string\n if (result === 'skipped') {\n status = messages.TestStepResultStatus.SKIPPED\n } else if (result === 'pending') {\n status = messages.TestStepResultStatus.PENDING\n } else if (doesHaveValue(error)) {\n message = formatError(error, filterStackTraces)\n status = messages.TestStepResultStatus.FAILED\n } else {\n status = messages.TestStepResultStatus.PASSED\n }\n\n return {\n duration,\n status,\n message,\n }\n}\n\nexport default { run }\n"]}
@@ -16,6 +16,7 @@ export interface INewTestCaseRunnerOptions {
16
16
  testCase: messages.TestCase;
17
17
  retries: number;
18
18
  skip: boolean;
19
+ filterStackTraces: boolean;
19
20
  supportCodeLibrary: ISupportCodeLibrary;
20
21
  worldParameters: any;
21
22
  }
@@ -31,11 +32,12 @@ export default class TestCaseRunner {
31
32
  private readonly testCase;
32
33
  private readonly maxAttempts;
33
34
  private readonly skip;
35
+ private readonly filterStackTraces;
34
36
  private readonly supportCodeLibrary;
35
37
  private testStepResults;
36
38
  private world;
37
39
  private readonly worldParameters;
38
- constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries, skip, supportCodeLibrary, worldParameters, }: INewTestCaseRunnerOptions);
40
+ constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries, skip, filterStackTraces, supportCodeLibrary, worldParameters, }: INewTestCaseRunnerOptions);
39
41
  resetTestProgressData(): void;
40
42
  getBeforeStepHookDefinitions(): TestStepHookDefinition[];
41
43
  getAfterStepHookDefinitions(): TestStepHookDefinition[];
@@ -45,6 +47,7 @@ export default class TestCaseRunner {
45
47
  shouldSkipHook(isBeforeHook: boolean): boolean;
46
48
  aroundTestStep(testStepId: string, runStepFn: () => Promise<messages.TestStepResult>): Promise<void>;
47
49
  run(): Promise<messages.TestStepResultStatus>;
50
+ runAttempt(attempt: number, moreAttemptsRemaining: boolean): Promise<boolean>;
48
51
  runHook(hookDefinition: TestCaseHookDefinition, hookParameter: ITestCaseHookParameter, isBeforeHook: boolean): Promise<messages.TestStepResult>;
49
52
  runStepHooks(stepHooks: TestStepHookDefinition[], pickleStep: messages.PickleStep, stepResult?: messages.TestStepResult): Promise<messages.TestStepResult[]>;
50
53
  runStep(pickleStep: messages.PickleStep, testStep: messages.TestStep): Promise<messages.TestStepResult>;
@@ -33,7 +33,7 @@ const messages = __importStar(require("@cucumber/messages"));
33
33
  const messages_1 = require("@cucumber/messages");
34
34
  const value_checker_1 = require("../value_checker");
35
35
  class TestCaseRunner {
36
- constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries = 0, skip, supportCodeLibrary, worldParameters, }) {
36
+ constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries = 0, skip, filterStackTraces, supportCodeLibrary, worldParameters, }) {
37
37
  this.attachmentManager = new attachment_manager_1.default(({ data, media }) => {
38
38
  if ((0, value_checker_1.doesNotHaveValue)(this.currentTestStepId)) {
39
39
  throw new Error('Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.');
@@ -57,6 +57,7 @@ class TestCaseRunner {
57
57
  this.pickle = pickle;
58
58
  this.testCase = testCase;
59
59
  this.skip = skip;
60
+ this.filterStackTraces = filterStackTraces;
60
61
  this.supportCodeLibrary = supportCodeLibrary;
61
62
  this.worldParameters = worldParameters;
62
63
  this.resetTestProgressData();
@@ -92,6 +93,7 @@ class TestCaseRunner {
92
93
  async invokeStep(step, stepDefinition, hookParameter) {
93
94
  return await step_runner_1.default.run({
94
95
  defaultTimeout: this.supportCodeLibrary.defaultTimeout,
96
+ filterStackTraces: this.filterStackTraces,
95
97
  hookParameter,
96
98
  step,
97
99
  stepDefinition,
@@ -130,52 +132,7 @@ class TestCaseRunner {
130
132
  async run() {
131
133
  for (let attempt = 0; attempt < this.maxAttempts; attempt++) {
132
134
  const moreAttemptsRemaining = attempt + 1 < this.maxAttempts;
133
- this.currentTestCaseStartedId = this.newId();
134
- const testCaseStarted = {
135
- testCaseStarted: {
136
- attempt,
137
- testCaseId: this.testCase.id,
138
- id: this.currentTestCaseStartedId,
139
- timestamp: this.stopwatch.timestamp(),
140
- },
141
- };
142
- this.eventBroadcaster.emit('envelope', testCaseStarted);
143
- // used to determine whether a hook is a Before or After
144
- let didWeRunStepsYet = false;
145
- for (const testStep of this.testCase.testSteps) {
146
- await this.aroundTestStep(testStep.id, async () => {
147
- if ((0, value_checker_1.doesHaveValue)(testStep.hookId)) {
148
- const hookParameter = {
149
- gherkinDocument: this.gherkinDocument,
150
- pickle: this.pickle,
151
- testCaseStartedId: this.currentTestCaseStartedId,
152
- };
153
- if (didWeRunStepsYet) {
154
- hookParameter.result = this.getWorstStepResult();
155
- hookParameter.willBeRetried =
156
- this.getWorstStepResult().status ===
157
- messages.TestStepResultStatus.FAILED && moreAttemptsRemaining;
158
- }
159
- return await this.runHook(findHookDefinition(testStep.hookId, this.supportCodeLibrary), hookParameter, !didWeRunStepsYet);
160
- }
161
- else {
162
- const pickleStep = this.pickle.steps.find((pickleStep) => pickleStep.id === testStep.pickleStepId);
163
- const testStepResult = await this.runStep(pickleStep, testStep);
164
- didWeRunStepsYet = true;
165
- return testStepResult;
166
- }
167
- });
168
- }
169
- const willBeRetried = this.getWorstStepResult().status ===
170
- messages.TestStepResultStatus.FAILED && moreAttemptsRemaining;
171
- const testCaseFinished = {
172
- testCaseFinished: {
173
- testCaseStartedId: this.currentTestCaseStartedId,
174
- timestamp: this.stopwatch.timestamp(),
175
- willBeRetried,
176
- },
177
- };
178
- this.eventBroadcaster.emit('envelope', testCaseFinished);
135
+ const willBeRetried = await this.runAttempt(attempt, moreAttemptsRemaining);
179
136
  if (!willBeRetried) {
180
137
  break;
181
138
  }
@@ -183,6 +140,55 @@ class TestCaseRunner {
183
140
  }
184
141
  return this.getWorstStepResult().status;
185
142
  }
143
+ async runAttempt(attempt, moreAttemptsRemaining) {
144
+ this.currentTestCaseStartedId = this.newId();
145
+ const testCaseStarted = {
146
+ testCaseStarted: {
147
+ attempt,
148
+ testCaseId: this.testCase.id,
149
+ id: this.currentTestCaseStartedId,
150
+ timestamp: this.stopwatch.timestamp(),
151
+ },
152
+ };
153
+ this.eventBroadcaster.emit('envelope', testCaseStarted);
154
+ // used to determine whether a hook is a Before or After
155
+ let didWeRunStepsYet = false;
156
+ for (const testStep of this.testCase.testSteps) {
157
+ await this.aroundTestStep(testStep.id, async () => {
158
+ if ((0, value_checker_1.doesHaveValue)(testStep.hookId)) {
159
+ const hookParameter = {
160
+ gherkinDocument: this.gherkinDocument,
161
+ pickle: this.pickle,
162
+ testCaseStartedId: this.currentTestCaseStartedId,
163
+ };
164
+ if (didWeRunStepsYet) {
165
+ hookParameter.result = this.getWorstStepResult();
166
+ hookParameter.willBeRetried =
167
+ this.getWorstStepResult().status ===
168
+ messages.TestStepResultStatus.FAILED && moreAttemptsRemaining;
169
+ }
170
+ return await this.runHook(findHookDefinition(testStep.hookId, this.supportCodeLibrary), hookParameter, !didWeRunStepsYet);
171
+ }
172
+ else {
173
+ const pickleStep = this.pickle.steps.find((pickleStep) => pickleStep.id === testStep.pickleStepId);
174
+ const testStepResult = await this.runStep(pickleStep, testStep);
175
+ didWeRunStepsYet = true;
176
+ return testStepResult;
177
+ }
178
+ });
179
+ }
180
+ const willBeRetried = this.getWorstStepResult().status ===
181
+ messages.TestStepResultStatus.FAILED && moreAttemptsRemaining;
182
+ const testCaseFinished = {
183
+ testCaseFinished: {
184
+ testCaseStartedId: this.currentTestCaseStartedId,
185
+ timestamp: this.stopwatch.timestamp(),
186
+ willBeRetried,
187
+ },
188
+ };
189
+ this.eventBroadcaster.emit('envelope', testCaseFinished);
190
+ return willBeRetried;
191
+ }
186
192
  async runHook(hookDefinition, hookParameter, isBeforeHook) {
187
193
  if (this.shouldSkipHook(isBeforeHook)) {
188
194
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"test_case_runner.js","sourceRoot":"","sources":["../../src/runtime/test_case_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAqD;AACrD,8EAAoD;AACpD,gEAAsC;AAC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,CAAC,YAAY,CAClD,aAAa,EACb,MAAM,CAAC,QAAQ,CAChB,CAAA;SACF;QACD,eAAe,CAAC,QAAQ,GAAG,aAAa,CAAA;QACxC,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AA7SD,iCA6SC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO;QACL,GAAG,kBAAkB,CAAC,6BAA6B;QACnD,GAAG,kBAAkB,CAAC,4BAA4B;KACnD,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,kBAAkB,CACzB,EAAU,EACV,kBAAuC;IAEvC,OAAO,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAC5C,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CACrC,CAAA;AACH,CAAC","sourcesContent":["import { getAmbiguousStepException } from './helpers'\nimport AttachmentManager from './attachment_manager'\nimport StepRunner from './step_runner'\nimport * as messages from '@cucumber/messages'\nimport { getWorstTestStepResult, IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport {\n ISupportCodeLibrary,\n ITestCaseHookParameter,\n ITestStepHookParameter,\n} from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport { IDefinition } from '../models/definition'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { ITestRunStopwatch } from './stopwatch'\nimport StepDefinition from '../models/step_definition'\n\nexport interface INewTestCaseRunnerOptions {\n eventBroadcaster: EventEmitter\n stopwatch: ITestRunStopwatch\n gherkinDocument: messages.GherkinDocument\n newId: IdGenerator.NewId\n pickle: messages.Pickle\n testCase: messages.TestCase\n retries: number\n skip: boolean\n supportCodeLibrary: ISupportCodeLibrary\n worldParameters: any\n}\n\nexport default class TestCaseRunner {\n private readonly attachmentManager: AttachmentManager\n private currentTestCaseStartedId: string\n private currentTestStepId: string\n private readonly eventBroadcaster: EventEmitter\n private readonly stopwatch: ITestRunStopwatch\n private readonly gherkinDocument: messages.GherkinDocument\n private readonly newId: IdGenerator.NewId\n private readonly pickle: messages.Pickle\n private readonly testCase: messages.TestCase\n private readonly maxAttempts: number\n private readonly skip: boolean\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private testStepResults: messages.TestStepResult[]\n private world: any\n private readonly worldParameters: any\n\n constructor({\n eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId,\n pickle,\n testCase,\n retries = 0,\n skip,\n supportCodeLibrary,\n worldParameters,\n }: INewTestCaseRunnerOptions) {\n this.attachmentManager = new AttachmentManager(({ data, media }) => {\n if (doesNotHaveValue(this.currentTestStepId)) {\n throw new Error(\n 'Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.'\n )\n }\n const attachment: messages.Envelope = {\n attachment: {\n body: data,\n contentEncoding: media.encoding,\n mediaType: media.contentType,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n },\n }\n this.eventBroadcaster.emit('envelope', attachment)\n })\n this.eventBroadcaster = eventBroadcaster\n this.stopwatch = stopwatch\n this.gherkinDocument = gherkinDocument\n this.maxAttempts = 1 + (skip ? 0 : retries)\n this.newId = newId\n this.pickle = pickle\n this.testCase = testCase\n this.skip = skip\n this.supportCodeLibrary = supportCodeLibrary\n this.worldParameters = worldParameters\n this.resetTestProgressData()\n }\n\n resetTestProgressData(): void {\n this.world = new this.supportCodeLibrary.World({\n attach: this.attachmentManager.create.bind(this.attachmentManager),\n log: this.attachmentManager.log.bind(this.attachmentManager),\n parameters: this.worldParameters,\n })\n this.testStepResults = []\n }\n\n getBeforeStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter(\n (hookDefinition) => hookDefinition.appliesToTestCase(this.pickle)\n )\n }\n\n getAfterStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.afterTestStepHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle))\n }\n\n getWorstStepResult(): messages.TestStepResult {\n if (this.testStepResults.length === 0) {\n return {\n status: this.skip\n ? messages.TestStepResultStatus.SKIPPED\n : messages.TestStepResultStatus.PASSED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return getWorstTestStepResult(this.testStepResults)\n }\n\n async invokeStep(\n step: messages.PickleStep,\n stepDefinition: IDefinition,\n hookParameter?: any\n ): Promise<messages.TestStepResult> {\n return await StepRunner.run({\n defaultTimeout: this.supportCodeLibrary.defaultTimeout,\n hookParameter,\n step,\n stepDefinition,\n world: this.world,\n })\n }\n\n isSkippingSteps(): boolean {\n return (\n this.getWorstStepResult().status !== messages.TestStepResultStatus.PASSED\n )\n }\n\n shouldSkipHook(isBeforeHook: boolean): boolean {\n return this.skip || (this.isSkippingSteps() && isBeforeHook)\n }\n\n async aroundTestStep(\n testStepId: string,\n runStepFn: () => Promise<messages.TestStepResult>\n ): Promise<void> {\n const testStepStarted: messages.Envelope = {\n testStepStarted: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepStarted)\n this.currentTestStepId = testStepId\n const testStepResult = await runStepFn()\n this.currentTestStepId = null\n this.testStepResults.push(testStepResult)\n const testStepFinished: messages.Envelope = {\n testStepFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n testStepResult,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepFinished)\n }\n\n async run(): Promise<messages.TestStepResultStatus> {\n for (let attempt = 0; attempt < this.maxAttempts; attempt++) {\n const moreAttemptsRemaining = attempt + 1 < this.maxAttempts\n this.currentTestCaseStartedId = this.newId()\n const testCaseStarted: messages.Envelope = {\n testCaseStarted: {\n attempt,\n testCaseId: this.testCase.id,\n id: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseStarted)\n // used to determine whether a hook is a Before or After\n let didWeRunStepsYet = false\n for (const testStep of this.testCase.testSteps) {\n await this.aroundTestStep(testStep.id, async () => {\n if (doesHaveValue(testStep.hookId)) {\n const hookParameter: ITestCaseHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n testCaseStartedId: this.currentTestCaseStartedId,\n }\n if (didWeRunStepsYet) {\n hookParameter.result = this.getWorstStepResult()\n hookParameter.willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n }\n return await this.runHook(\n findHookDefinition(testStep.hookId, this.supportCodeLibrary),\n hookParameter,\n !didWeRunStepsYet\n )\n } else {\n const pickleStep = this.pickle.steps.find(\n (pickleStep) => pickleStep.id === testStep.pickleStepId\n )\n const testStepResult = await this.runStep(pickleStep, testStep)\n didWeRunStepsYet = true\n return testStepResult\n }\n })\n }\n\n const willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n const testCaseFinished: messages.Envelope = {\n testCaseFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n willBeRetried,\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseFinished)\n if (!willBeRetried) {\n break\n }\n this.resetTestProgressData()\n }\n return this.getWorstStepResult().status\n }\n\n async runHook(\n hookDefinition: TestCaseHookDefinition,\n hookParameter: ITestCaseHookParameter,\n isBeforeHook: boolean\n ): Promise<messages.TestStepResult> {\n if (this.shouldSkipHook(isBeforeHook)) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return await this.invokeStep(null, hookDefinition, hookParameter)\n }\n\n async runStepHooks(\n stepHooks: TestStepHookDefinition[],\n pickleStep: messages.PickleStep,\n stepResult?: messages.TestStepResult\n ): Promise<messages.TestStepResult[]> {\n const stepHooksResult = []\n const hookParameter: ITestStepHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n pickleStep,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n result: stepResult,\n }\n for (const stepHookDefinition of stepHooks) {\n stepHooksResult.push(\n await this.invokeStep(null, stepHookDefinition, hookParameter)\n )\n }\n return stepHooksResult\n }\n\n async runStep(\n pickleStep: messages.PickleStep,\n testStep: messages.TestStep\n ): Promise<messages.TestStepResult> {\n const stepDefinitions = testStep.stepDefinitionIds.map(\n (stepDefinitionId) => {\n return findStepDefinition(stepDefinitionId, this.supportCodeLibrary)\n }\n )\n if (stepDefinitions.length === 0) {\n return {\n status: messages.TestStepResultStatus.UNDEFINED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (stepDefinitions.length > 1) {\n return {\n message: getAmbiguousStepException(stepDefinitions),\n status: messages.TestStepResultStatus.AMBIGUOUS,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (this.isSkippingSteps()) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n\n let stepResult\n let stepResults = await this.runStepHooks(\n this.getBeforeStepHookDefinitions(),\n pickleStep\n )\n if (\n getWorstTestStepResult(stepResults).status !==\n messages.TestStepResultStatus.FAILED\n ) {\n stepResult = await this.invokeStep(pickleStep, stepDefinitions[0])\n stepResults.push(stepResult)\n }\n const afterStepHookResults = await this.runStepHooks(\n this.getAfterStepHookDefinitions(),\n pickleStep,\n stepResult\n )\n stepResults = stepResults.concat(afterStepHookResults)\n\n const finalStepResult = getWorstTestStepResult(stepResults)\n let finalDuration = messages.TimeConversion.millisecondsToDuration(0)\n for (const result of stepResults) {\n finalDuration = messages.TimeConversion.addDurations(\n finalDuration,\n result.duration\n )\n }\n finalStepResult.duration = finalDuration\n return finalStepResult\n }\n}\n\nfunction findHookDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): TestCaseHookDefinition {\n return [\n ...supportCodeLibrary.beforeTestCaseHookDefinitions,\n ...supportCodeLibrary.afterTestCaseHookDefinitions,\n ].find((definition) => definition.id === id)\n}\n\nfunction findStepDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): StepDefinition {\n return supportCodeLibrary.stepDefinitions.find(\n (definition) => definition.id === id\n )\n}\n"]}
1
+ {"version":3,"file":"test_case_runner.js","sourceRoot":"","sources":["../../src/runtime/test_case_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAqD;AACrD,8EAAoD;AACpD,gEAAsC;AACtC,6DAA8C;AAC9C,iDAAwE;AAUxE,oDAAkE;AAkBlE,MAAqB,cAAc;IAkBjC,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,IAAI,EACJ,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GACW;QAC1B,IAAI,CAAC,iBAAiB,GAAG,IAAI,4BAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;YACjE,IAAI,IAAA,gCAAgB,EAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;gBAC5C,MAAM,IAAI,KAAK,CACb,sGAAsG,CACvG,CAAA;aACF;YACD,MAAM,UAAU,GAAsB;gBACpC,UAAU,EAAE;oBACV,IAAI,EAAE,IAAI;oBACV,eAAe,EAAE,KAAK,CAAC,QAAQ;oBAC/B,SAAS,EAAE,KAAK,CAAC,WAAW;oBAC5B,iBAAiB,EAAE,IAAI,CAAC,wBAAwB;oBAChD,UAAU,EAAE,IAAI,CAAC,iBAAiB;iBACnC;aACF,CAAA;YACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;Q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U,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CACrC,CAAA;AACH,CAAC","sourcesContent":["import { getAmbiguousStepException } from './helpers'\nimport AttachmentManager from './attachment_manager'\nimport StepRunner from './step_runner'\nimport * as messages from '@cucumber/messages'\nimport { getWorstTestStepResult, IdGenerator } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport {\n ISupportCodeLibrary,\n ITestCaseHookParameter,\n ITestStepHookParameter,\n} from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport { IDefinition } from '../models/definition'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { ITestRunStopwatch } from './stopwatch'\nimport StepDefinition from '../models/step_definition'\n\nexport interface INewTestCaseRunnerOptions {\n eventBroadcaster: EventEmitter\n stopwatch: ITestRunStopwatch\n gherkinDocument: messages.GherkinDocument\n newId: IdGenerator.NewId\n pickle: messages.Pickle\n testCase: messages.TestCase\n retries: number\n skip: boolean\n filterStackTraces: boolean\n supportCodeLibrary: ISupportCodeLibrary\n worldParameters: any\n}\n\nexport default class TestCaseRunner {\n private readonly attachmentManager: AttachmentManager\n private currentTestCaseStartedId: string\n private currentTestStepId: string\n private readonly eventBroadcaster: EventEmitter\n private readonly stopwatch: ITestRunStopwatch\n private readonly gherkinDocument: messages.GherkinDocument\n private readonly newId: IdGenerator.NewId\n private readonly pickle: messages.Pickle\n private readonly testCase: messages.TestCase\n private readonly maxAttempts: number\n private readonly skip: boolean\n private readonly filterStackTraces: boolean\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private testStepResults: messages.TestStepResult[]\n private world: any\n private readonly worldParameters: any\n\n constructor({\n eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId,\n pickle,\n testCase,\n retries = 0,\n skip,\n filterStackTraces,\n supportCodeLibrary,\n worldParameters,\n }: INewTestCaseRunnerOptions) {\n this.attachmentManager = new AttachmentManager(({ data, media }) => {\n if (doesNotHaveValue(this.currentTestStepId)) {\n throw new Error(\n 'Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.'\n )\n }\n const attachment: messages.Envelope = {\n attachment: {\n body: data,\n contentEncoding: media.encoding,\n mediaType: media.contentType,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n },\n }\n this.eventBroadcaster.emit('envelope', attachment)\n })\n this.eventBroadcaster = eventBroadcaster\n this.stopwatch = stopwatch\n this.gherkinDocument = gherkinDocument\n this.maxAttempts = 1 + (skip ? 0 : retries)\n this.newId = newId\n this.pickle = pickle\n this.testCase = testCase\n this.skip = skip\n this.filterStackTraces = filterStackTraces\n this.supportCodeLibrary = supportCodeLibrary\n this.worldParameters = worldParameters\n this.resetTestProgressData()\n }\n\n resetTestProgressData(): void {\n this.world = new this.supportCodeLibrary.World({\n attach: this.attachmentManager.create.bind(this.attachmentManager),\n log: this.attachmentManager.log.bind(this.attachmentManager),\n parameters: this.worldParameters,\n })\n this.testStepResults = []\n }\n\n getBeforeStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter(\n (hookDefinition) => hookDefinition.appliesToTestCase(this.pickle)\n )\n }\n\n getAfterStepHookDefinitions(): TestStepHookDefinition[] {\n return this.supportCodeLibrary.afterTestStepHookDefinitions\n .slice(0)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle))\n }\n\n getWorstStepResult(): messages.TestStepResult {\n if (this.testStepResults.length === 0) {\n return {\n status: this.skip\n ? messages.TestStepResultStatus.SKIPPED\n : messages.TestStepResultStatus.PASSED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return getWorstTestStepResult(this.testStepResults)\n }\n\n async invokeStep(\n step: messages.PickleStep,\n stepDefinition: IDefinition,\n hookParameter?: any\n ): Promise<messages.TestStepResult> {\n return await StepRunner.run({\n defaultTimeout: this.supportCodeLibrary.defaultTimeout,\n filterStackTraces: this.filterStackTraces,\n hookParameter,\n step,\n stepDefinition,\n world: this.world,\n })\n }\n\n isSkippingSteps(): boolean {\n return (\n this.getWorstStepResult().status !== messages.TestStepResultStatus.PASSED\n )\n }\n\n shouldSkipHook(isBeforeHook: boolean): boolean {\n return this.skip || (this.isSkippingSteps() && isBeforeHook)\n }\n\n async aroundTestStep(\n testStepId: string,\n runStepFn: () => Promise<messages.TestStepResult>\n ): Promise<void> {\n const testStepStarted: messages.Envelope = {\n testStepStarted: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepStarted)\n this.currentTestStepId = testStepId\n const testStepResult = await runStepFn()\n this.currentTestStepId = null\n this.testStepResults.push(testStepResult)\n const testStepFinished: messages.Envelope = {\n testStepFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n testStepResult,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testStepFinished)\n }\n\n async run(): Promise<messages.TestStepResultStatus> {\n for (let attempt = 0; attempt < this.maxAttempts; attempt++) {\n const moreAttemptsRemaining = attempt + 1 < this.maxAttempts\n\n const willBeRetried = await this.runAttempt(\n attempt,\n moreAttemptsRemaining\n )\n\n if (!willBeRetried) {\n break\n }\n this.resetTestProgressData()\n }\n return this.getWorstStepResult().status\n }\n\n async runAttempt(\n attempt: number,\n moreAttemptsRemaining: boolean\n ): Promise<boolean> {\n this.currentTestCaseStartedId = this.newId()\n const testCaseStarted: messages.Envelope = {\n testCaseStarted: {\n attempt,\n testCaseId: this.testCase.id,\n id: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseStarted)\n // used to determine whether a hook is a Before or After\n let didWeRunStepsYet = false\n for (const testStep of this.testCase.testSteps) {\n await this.aroundTestStep(testStep.id, async () => {\n if (doesHaveValue(testStep.hookId)) {\n const hookParameter: ITestCaseHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n testCaseStartedId: this.currentTestCaseStartedId,\n }\n if (didWeRunStepsYet) {\n hookParameter.result = this.getWorstStepResult()\n hookParameter.willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n }\n return await this.runHook(\n findHookDefinition(testStep.hookId, this.supportCodeLibrary),\n hookParameter,\n !didWeRunStepsYet\n )\n } else {\n const pickleStep = this.pickle.steps.find(\n (pickleStep) => pickleStep.id === testStep.pickleStepId\n )\n const testStepResult = await this.runStep(pickleStep, testStep)\n didWeRunStepsYet = true\n return testStepResult\n }\n })\n }\n\n const willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && moreAttemptsRemaining\n const testCaseFinished: messages.Envelope = {\n testCaseFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n willBeRetried,\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseFinished)\n\n return willBeRetried\n }\n\n async runHook(\n hookDefinition: TestCaseHookDefinition,\n hookParameter: ITestCaseHookParameter,\n isBeforeHook: boolean\n ): Promise<messages.TestStepResult> {\n if (this.shouldSkipHook(isBeforeHook)) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n return await this.invokeStep(null, hookDefinition, hookParameter)\n }\n\n async runStepHooks(\n stepHooks: TestStepHookDefinition[],\n pickleStep: messages.PickleStep,\n stepResult?: messages.TestStepResult\n ): Promise<messages.TestStepResult[]> {\n const stepHooksResult = []\n const hookParameter: ITestStepHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n pickleStep,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n result: stepResult,\n }\n for (const stepHookDefinition of stepHooks) {\n stepHooksResult.push(\n await this.invokeStep(null, stepHookDefinition, hookParameter)\n )\n }\n return stepHooksResult\n }\n\n async runStep(\n pickleStep: messages.PickleStep,\n testStep: messages.TestStep\n ): Promise<messages.TestStepResult> {\n const stepDefinitions = testStep.stepDefinitionIds.map(\n (stepDefinitionId) => {\n return findStepDefinition(stepDefinitionId, this.supportCodeLibrary)\n }\n )\n if (stepDefinitions.length === 0) {\n return {\n status: messages.TestStepResultStatus.UNDEFINED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (stepDefinitions.length > 1) {\n return {\n message: getAmbiguousStepException(stepDefinitions),\n status: messages.TestStepResultStatus.AMBIGUOUS,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n } else if (this.isSkippingSteps()) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n }\n }\n\n let stepResult\n let stepResults = await this.runStepHooks(\n this.getBeforeStepHookDefinitions(),\n pickleStep\n )\n if (\n getWorstTestStepResult(stepResults).status !==\n messages.TestStepResultStatus.FAILED\n ) {\n stepResult = await this.invokeStep(pickleStep, stepDefinitions[0])\n stepResults.push(stepResult)\n }\n const afterStepHookResults = await this.runStepHooks(\n this.getAfterStepHookDefinitions(),\n pickleStep,\n stepResult\n )\n stepResults = stepResults.concat(afterStepHookResults)\n\n const finalStepResult = getWorstTestStepResult(stepResults)\n let finalDuration = messages.TimeConversion.millisecondsToDuration(0)\n for (const result of stepResults) {\n finalDuration = messages.TimeConversion.addDurations(\n finalDuration,\n result.duration\n )\n }\n finalStepResult.duration = finalDuration\n return finalStepResult\n }\n}\n\nfunction findHookDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): TestCaseHookDefinition {\n return [\n ...supportCodeLibrary.beforeTestCaseHookDefinitions,\n ...supportCodeLibrary.afterTestCaseHookDefinitions,\n ].find((definition) => definition.id === id)\n}\n\nfunction findStepDefinition(\n id: string,\n supportCodeLibrary: ISupportCodeLibrary\n): StepDefinition {\n return supportCodeLibrary.stepDefinitions.find(\n (definition) => definition.id === id\n )\n}\n"]}
@@ -1,3 +1,3 @@
1
- import { isFileNameInCucumber } from '../stack_trace_filter';
1
+ import { isFileNameInCucumber } from '../filter_stack_trace';
2
2
  import { ILineAndUri } from '../types';
3
3
  export declare function getDefinitionLineAndUri(cwd: string, isExcluded?: typeof isFileNameInCucumber): ILineAndUri;
@@ -5,15 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getDefinitionLineAndUri = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const source_map_support_1 = require("@cspotcode/source-map-support");
9
- const stack_chain_1 = __importDefault(require("stack-chain"));
10
- const stack_trace_filter_1 = require("../stack_trace_filter");
8
+ const error_stack_parser_1 = __importDefault(require("error-stack-parser"));
9
+ const filter_stack_trace_1 = require("../filter_stack_trace");
11
10
  const value_checker_1 = require("../value_checker");
12
- function getDefinitionLineAndUri(cwd, isExcluded = stack_trace_filter_1.isFileNameInCucumber) {
11
+ function getDefinitionLineAndUri(cwd, isExcluded = filter_stack_trace_1.isFileNameInCucumber) {
13
12
  let line;
14
13
  let uri;
15
- const stackframes = stack_chain_1.default.callSite().map(source_map_support_1.wrapCallSite);
16
- const stackframe = stackframes.find((frame) => frame.getFileName() !== __filename && !isExcluded(frame.getFileName()));
14
+ const stackframes = error_stack_parser_1.default.parse(new Error());
15
+ const stackframe = stackframes.find((frame) => frame.fileName !== __filename && !isExcluded(frame.fileName));
17
16
  if (stackframe != null) {
18
17
  line = stackframe.getLineNumber();
19
18
  uri = stackframe.getFileName();
@@ -1 +1 @@
1
- {"version":3,"file":"get_definition_line_and_uri.js","sourceRoot":"","sources":["../../src/support_code_library_builder/get_definition_line_and_uri.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,sEAA4D;AAC5D,8DAAoC;AACpC,8DAA4D;AAC5D,oDAAgE;AAIhE,SAAgB,uBAAuB,CACrC,GAAW,EACX,UAAU,GAAG,yCAAoB;IAEjC,IAAI,IAAY,CAAA;IAChB,IAAI,GAAW,CAAA;IAEf,MAAM,WAAW,GAAe,qBAAU,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,iCAAY,CAAC,CAAA;IACvE,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CACjC,CAAC,KAAe,EAAE,EAAE,CAClB,KAAK,CAAC,WAAW,EAAE,KAAK,UAAU,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CACzE,CAAA;IACD,IAAI,UAAU,IAAI,IAAI,EAAE;QACtB,IAAI,GAAG,UAAU,CAAC,aAAa,EAAE,CAAA;QACjC,GAAG,GAAG,UAAU,CAAC,WAAW,EAAE,CAAA;QAC9B,IAAI,IAAA,6BAAa,EAAC,GAAG,CAAC,EAAE;YACtB,GAAG,GAAG,cAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;SAC9B;KACF;IAED,OAAO;QACL,IAAI,EAAE,IAAA,8BAAc,EAAC,IAAI,EAAE,CAAC,CAAC;QAC7B,GAAG,EAAE,IAAA,8BAAc,EAAC,GAAG,EAAE,SAAS,CAAC;KACpC,CAAA;AACH,CAAC;AAxBD,0DAwBC","sourcesContent":["import path from 'path'\nimport { wrapCallSite } from '@cspotcode/source-map-support'\nimport stackChain from 'stack-chain'\nimport { isFileNameInCucumber } from '../stack_trace_filter'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport { ILineAndUri } from '../types'\nimport CallSite = NodeJS.CallSite\n\nexport function getDefinitionLineAndUri(\n cwd: string,\n isExcluded = isFileNameInCucumber\n): ILineAndUri {\n let line: number\n let uri: string\n\n const stackframes: CallSite[] = stackChain.callSite().map(wrapCallSite)\n const stackframe = stackframes.find(\n (frame: CallSite) =>\n frame.getFileName() !== __filename && !isExcluded(frame.getFileName())\n )\n if (stackframe != null) {\n line = stackframe.getLineNumber()\n uri = stackframe.getFileName()\n if (doesHaveValue(uri)) {\n uri = path.relative(cwd, uri)\n }\n }\n\n return {\n line: valueOrDefault(line, 0),\n uri: valueOrDefault(uri, 'unknown'),\n }\n}\n"]}
1
+ {"version":3,"file":"get_definition_line_and_uri.js","sourceRoot":"","sources":["../../src/support_code_library_builder/get_definition_line_and_uri.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,4EAAiE;AACjE,8DAA4D;AAC5D,oDAAgE;AAGhE,SAAgB,uBAAuB,CACrC,GAAW,EACX,UAAU,GAAG,yCAAoB;IAEjC,IAAI,IAAY,CAAA;IAChB,IAAI,GAAW,CAAA;IACf,MAAM,WAAW,GAAiB,4BAAgB,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAA;IACrE,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CACjC,CAAC,KAAiB,EAAE,EAAE,CACpB,KAAK,CAAC,QAAQ,KAAK,UAAU,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAC/D,CAAA;IACD,IAAI,UAAU,IAAI,IAAI,EAAE;QACtB,IAAI,GAAG,UAAU,CAAC,aAAa,EAAE,CAAA;QACjC,GAAG,GAAG,UAAU,CAAC,WAAW,EAAE,CAAA;QAC9B,IAAI,IAAA,6BAAa,EAAC,GAAG,CAAC,EAAE;YACtB,GAAG,GAAG,cAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;SAC9B;KACF;IAED,OAAO;QACL,IAAI,EAAE,IAAA,8BAAc,EAAC,IAAI,EAAE,CAAC,CAAC;QAC7B,GAAG,EAAE,IAAA,8BAAc,EAAC,GAAG,EAAE,SAAS,CAAC;KACpC,CAAA;AACH,CAAC;AAvBD,0DAuBC","sourcesContent":["import path from 'path'\nimport errorStackParser, { StackFrame } from 'error-stack-parser'\nimport { isFileNameInCucumber } from '../filter_stack_trace'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport { ILineAndUri } from '../types'\n\nexport function getDefinitionLineAndUri(\n cwd: string,\n isExcluded = isFileNameInCucumber\n): ILineAndUri {\n let line: number\n let uri: string\n const stackframes: StackFrame[] = errorStackParser.parse(new Error())\n const stackframe = stackframes.find(\n (frame: StackFrame) =>\n frame.fileName !== __filename && !isExcluded(frame.fileName)\n )\n if (stackframe != null) {\n line = stackframe.getLineNumber()\n uri = stackframe.getFileName()\n if (doesHaveValue(uri)) {\n uri = path.relative(cwd, uri)\n }\n }\n\n return {\n line: valueOrDefault(line, 0),\n uri: valueOrDefault(uri, 'unknown'),\n }\n}\n"]}
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "8.7.0";
1
+ export declare const version = "8.9.0";
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.7.0';
5
+ exports.version = '8.9.0';
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.7.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.0'\n"]}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "gherkin",
9
9
  "tests"
10
10
  ],
11
- "version": "8.7.0",
11
+ "version": "8.9.0",
12
12
  "homepage": "https://github.com/cucumber/cucumber-js",
13
13
  "author": "Julien Biezemans <jb@jbpros.com>",
14
14
  "contributors": [
@@ -88,6 +88,7 @@
88
88
  "Kevin Goslar <kevin.goslar@gmail.com>",
89
89
  "Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com>",
90
90
  "Kim, Jang-hwan <janghwan@gmail.com>",
91
+ "Konstantin Epishev <konstantin@epishev.me>",
91
92
  "kostya.misura <kostya.misura@gmail.com>",
92
93
  "Krispin Schulz <krispin.schulz@blackbridge.com>",
93
94
  "Kushal Pisavadia",
@@ -195,15 +196,14 @@
195
196
  "node": "12 || 14 || 16 || 17 || 18"
196
197
  },
197
198
  "dependencies": {
198
- "@cspotcode/source-map-support": "^0.8.0",
199
199
  "@cucumber/ci-environment": "9.1.0",
200
200
  "@cucumber/cucumber-expressions": "16.0.0",
201
- "@cucumber/gherkin": "24.0.0",
201
+ "@cucumber/gherkin": "24.1.0",
202
202
  "@cucumber/gherkin-streams": "5.0.1",
203
- "@cucumber/gherkin-utils": "8.0.0",
203
+ "@cucumber/gherkin-utils": "8.0.1",
204
204
  "@cucumber/html-formatter": "20.1.0",
205
205
  "@cucumber/message-streams": "4.0.1",
206
- "@cucumber/messages": "19.1.4",
206
+ "@cucumber/messages": "20.0.0",
207
207
  "@cucumber/tag-expressions": "4.1.0",
208
208
  "assertion-error-formatter": "^3.0.0",
209
209
  "capital-case": "^1.0.4",
@@ -213,6 +213,7 @@
213
213
  "debug": "^4.3.4",
214
214
  "duration": "^0.2.2",
215
215
  "durations": "^3.4.2",
216
+ "error-stack-parser": "^2.1.4",
216
217
  "figures": "^3.2.0",
217
218
  "glob": "^7.1.6",
218
219
  "has-ansi": "^4.0.1",
@@ -225,26 +226,27 @@
225
226
  "mz": "^2.7.0",
226
227
  "progress": "^2.0.3",
227
228
  "resolve-pkg": "^2.0.0",
228
- "semver": "7.3.7",
229
- "stack-chain": "^2.0.0",
229
+ "semver": "7.3.8",
230
230
  "string-argv": "^0.3.1",
231
231
  "strip-ansi": "6.0.1",
232
232
  "supports-color": "^8.1.1",
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
241
  "@cucumber/query": "12.0.0",
241
- "@microsoft/api-documenter": "7.19.1",
242
- "@microsoft/api-extractor": "7.32.0",
242
+ "@microsoft/api-documenter": "7.19.23",
243
+ "@microsoft/api-extractor": "7.33.5",
243
244
  "@sinonjs/fake-timers": "9.1.2",
244
245
  "@types/chai": "4.3.3",
246
+ "@types/chai-xml": "^0.3.2",
245
247
  "@types/debug": "4.1.7",
246
248
  "@types/dirty-chai": "2.0.2",
247
- "@types/express": "4.17.13",
249
+ "@types/express": "4.17.14",
248
250
  "@types/fs-extra": "9.0.13",
249
251
  "@types/glob": "7.2.0",
250
252
  "@types/has-ansi": "5.0.0",
@@ -253,37 +255,38 @@
253
255
  "@types/mocha": "10.0.0",
254
256
  "@types/mustache": "4.2.1",
255
257
  "@types/mz": "2.7.4",
256
- "@types/node": "16.11.62",
258
+ "@types/node": "18.11.9",
257
259
  "@types/progress": "2.0.5",
258
- "@types/semver": "7.3.12",
260
+ "@types/semver": "7.3.13",
259
261
  "@types/sinon-chai": "3.2.8",
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.38.1",
265
- "@typescript-eslint/parser": "5.38.1",
266
+ "@typescript-eslint/eslint-plugin": "5.42.0",
267
+ "@typescript-eslint/parser": "5.42.0",
266
268
  "chai": "4.3.6",
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.24.0",
274
+ "eslint": "8.26.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",
275
278
  "eslint-plugin-prettier": "4.2.1",
276
279
  "eslint-plugin-standard": "4.1.0",
277
- "express": "4.18.1",
280
+ "express": "4.18.2",
278
281
  "fs-extra": "10.1.0",
279
282
  "genversion": "3.1.1",
280
- "mocha": "10.0.0",
283
+ "mocha": "10.1.0",
281
284
  "mustache": "4.2.0",
282
285
  "nyc": "15.1.0",
283
286
  "prettier": "2.7.1",
284
287
  "reindent-template-literals": "1.1.0",
285
288
  "shx": "0.3.4",
286
- "sinon": "14.0.0",
289
+ "sinon": "14.0.1",
287
290
  "sinon-chai": "3.7.0",
288
291
  "stream-buffers": "3.0.2",
289
292
  "stream-to-string": "1.2.0",
@@ -311,7 +314,7 @@
311
314
  "prepublishOnly": "rm -rf lib && npm run build-local",
312
315
  "pretest-coverage": "npm run build-local",
313
316
  "pretypes-test": "npm run build-local",
314
- "test-coverage": "nyc --silent mocha 'src/**/*_spec.ts' 'compatibility/**/*_spec.ts' && nyc --silent --no-clean node bin/cucumber.js && nyc report --reporter=lcov",
317
+ "test-coverage": "nyc --silent mocha 'src/**/*_spec.ts' 'compatibility/**/*_spec.ts' && nyc --silent --no-clean node bin/cucumber.js --tags \"not @source-mapping\" && nyc report --reporter=lcov",
315
318
  "test": "npm run lint && npm run types-test && npm run unit-test && npm run cck-test && npm run feature-test",
316
319
  "types-test": "tsd",
317
320
  "unit-test": "mocha 'src/**/*_spec.ts'",
@@ -1,11 +0,0 @@
1
- /// <reference types="node" />
2
- import CallSite = NodeJS.CallSite;
3
- export declare function isFileNameInCucumber(fileName: string): boolean;
4
- export default class StackTraceFilter {
5
- private currentFilter;
6
- filter(): void;
7
- isErrorInCucumber(frames: CallSite[]): boolean;
8
- isFrameInCucumber(frame: CallSite): boolean;
9
- isFrameInNode(frame: CallSite): boolean;
10
- unfilter(): void;
11
- }
@@ -1,46 +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
- exports.isFileNameInCucumber = void 0;
7
- const stack_chain_1 = __importDefault(require("stack-chain"));
8
- const path_1 = __importDefault(require("path"));
9
- const value_checker_1 = require("./value_checker");
10
- const projectRootPath = path_1.default.join(__dirname, '..');
11
- const projectChildDirs = ['src', 'lib', 'node_modules'];
12
- function isFileNameInCucumber(fileName) {
13
- return projectChildDirs.some((dir) => fileName.startsWith(path_1.default.join(projectRootPath, dir)));
14
- }
15
- exports.isFileNameInCucumber = isFileNameInCucumber;
16
- class StackTraceFilter {
17
- filter() {
18
- this.currentFilter = stack_chain_1.default.filter.attach((_err, frames) => {
19
- if (this.isErrorInCucumber(frames)) {
20
- return frames;
21
- }
22
- const index = frames.findIndex((x) => this.isFrameInCucumber(x));
23
- if (index === -1) {
24
- return frames;
25
- }
26
- return frames.slice(0, index);
27
- });
28
- }
29
- isErrorInCucumber(frames) {
30
- const filteredFrames = frames.filter((x) => !this.isFrameInNode(x));
31
- return (filteredFrames.length > 0 && this.isFrameInCucumber(filteredFrames[0]));
32
- }
33
- isFrameInCucumber(frame) {
34
- const fileName = (0, value_checker_1.valueOrDefault)(frame.getFileName(), '');
35
- return isFileNameInCucumber(fileName);
36
- }
37
- isFrameInNode(frame) {
38
- const fileName = (0, value_checker_1.valueOrDefault)(frame.getFileName(), '');
39
- return !fileName.includes(path_1.default.sep);
40
- }
41
- unfilter() {
42
- stack_chain_1.default.filter.deattach(this.currentFilter);
43
- }
44
- }
45
- exports.default = StackTraceFilter;
46
- //# sourceMappingURL=stack_trace_filter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stack_trace_filter.js","sourceRoot":"","sources":["../src/stack_trace_filter.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAoC;AACpC,gDAAuB;AACvB,mDAAgD;AAGhD,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;AAClD,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;AAEvD,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,OAAO,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C,KAAK,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAA;QACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAI,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC;IAED,QAAQ;QACN,qBAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IAChD,CAAC;CACF;AAtCD,mCAsCC","sourcesContent":["import stackChain from 'stack-chain'\nimport path from 'path'\nimport { valueOrDefault } from './value_checker'\nimport CallSite = NodeJS.CallSite\n\nconst projectRootPath = path.join(__dirname, '..')\nconst projectChildDirs = ['src', 'lib', 'node_modules']\n\nexport function isFileNameInCucumber(fileName: string): boolean {\n return projectChildDirs.some((dir) =>\n fileName.startsWith(path.join(projectRootPath, dir))\n )\n}\n\nexport default class StackTraceFilter {\n private currentFilter: CallSite[]\n\n filter(): void {\n this.currentFilter = stackChain.filter.attach(\n (_err: any, frames: CallSite[]) => {\n if (this.isErrorInCucumber(frames)) {\n return frames\n }\n const index = frames.findIndex((x) => this.isFrameInCucumber(x))\n if (index === -1) {\n return frames\n }\n return frames.slice(0, index)\n }\n )\n }\n\n isErrorInCucumber(frames: CallSite[]): boolean {\n const filteredFrames = frames.filter((x) => !this.isFrameInNode(x))\n return (\n filteredFrames.length > 0 && this.isFrameInCucumber(filteredFrames[0])\n )\n }\n\n isFrameInCucumber(frame: CallSite): boolean {\n const fileName = valueOrDefault(frame.getFileName(), '')\n return isFileNameInCucumber(fileName)\n }\n\n isFrameInNode(frame: CallSite): boolean {\n const fileName = valueOrDefault(frame.getFileName(), '')\n return !fileName.includes(path.sep)\n }\n\n unfilter(): void {\n stackChain.filter.deattach(this.currentFilter)\n }\n}\n"]}