@cucumber/cucumber 7.2.1 → 8.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/lib/cli/argv_parser.d.ts +1 -2
- package/lib/cli/argv_parser.js +8 -12
- package/lib/cli/argv_parser.js.map +1 -1
- package/lib/cli/configuration_builder.d.ts +0 -1
- package/lib/cli/configuration_builder.js +20 -21
- package/lib/cli/configuration_builder.js.map +1 -1
- package/lib/cli/helpers.d.ts +1 -0
- package/lib/cli/helpers.js +49 -22
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/i18n.js +6 -6
- package/lib/cli/i18n.js.map +1 -1
- package/lib/cli/index.d.ts +1 -1
- package/lib/cli/index.js +35 -29
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/profile_loader.d.ts +3 -3
- package/lib/cli/profile_loader.js +17 -10
- package/lib/cli/profile_loader.js.map +1 -1
- package/lib/cli/publish_banner.js +1 -1
- package/lib/cli/publish_banner.js.map +1 -1
- package/lib/formatter/builder.d.ts +5 -4
- package/lib/formatter/builder.js +38 -52
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/get_color_fns.d.ts +6 -2
- package/lib/formatter/get_color_fns.js +18 -12
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +15 -17
- package/lib/formatter/helpers/event_data_collector.js +19 -12
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/formatter/helpers/formatters.d.ts +6 -0
- package/lib/formatter/helpers/formatters.js +41 -0
- package/lib/formatter/helpers/formatters.js.map +1 -0
- package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -6
- package/lib/formatter/helpers/gherkin_document_parser.js +24 -40
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +6 -6
- package/lib/formatter/helpers/issue_helpers.js +6 -8
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/keyword_type.js +1 -5
- package/lib/formatter/helpers/keyword_type.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.d.ts +9 -10
- package/lib/formatter/helpers/pickle_parser.js +8 -17
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -2
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.d.ts +2 -2
- package/lib/formatter/helpers/summary_helpers.js +39 -20
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +34 -15
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +5 -5
- package/lib/formatter/helpers/test_case_attempt_parser.js +30 -15
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.d.ts +3 -3
- package/lib/formatter/helpers/usage_helpers/index.js +48 -45
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
- package/lib/formatter/html_formatter.d.ts +1 -0
- package/lib/formatter/html_formatter.js +2 -1
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/http_stream.js +1 -1
- package/lib/formatter/http_stream.js.map +1 -1
- package/lib/formatter/index.d.ts +1 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +22 -27
- package/lib/formatter/json_formatter.js +62 -30
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.d.ts +1 -0
- package/lib/formatter/message_formatter.js +2 -1
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +7 -6
- package/lib/formatter/progress_bar_formatter.js +5 -4
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +3 -2
- package/lib/formatter/progress_formatter.js +30 -10
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/rerun_formatter.d.ts +1 -0
- package/lib/formatter/rerun_formatter.js +33 -11
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.d.ts +1 -0
- package/lib/formatter/snippets_formatter.js +22 -2
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +3 -3
- package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +3 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +1 -1
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -1
- package/lib/formatter/summary_formatter.d.ts +3 -2
- package/lib/formatter/summary_formatter.js +4 -4
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.d.ts +1 -0
- package/lib/formatter/usage_formatter.js +24 -5
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.d.ts +1 -0
- package/lib/formatter/usage_json_formatter.js +1 -0
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/importer.js +13 -0
- package/lib/index.d.ts +15 -12
- package/lib/index.js +6 -3
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.d.ts +3 -4
- package/lib/models/data_table.js +9 -7
- package/lib/models/data_table.js.map +1 -1
- package/lib/models/definition.d.ts +2 -2
- package/lib/models/definition.js.map +1 -1
- package/lib/models/step_definition.js +1 -2
- package/lib/models/step_definition.js.map +1 -1
- package/lib/models/test_case_hook_definition.d.ts +2 -2
- package/lib/models/test_case_hook_definition.js.map +1 -1
- package/lib/models/test_step_hook_definition.d.ts +2 -2
- package/lib/models/test_step_hook_definition.js.map +1 -1
- package/lib/pickle_filter.d.ts +9 -11
- package/lib/pickle_filter.js +9 -9
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/assemble_test_cases.d.ts +13 -0
- package/lib/runtime/assemble_test_cases.js +88 -0
- package/lib/runtime/assemble_test_cases.js.map +1 -0
- package/lib/runtime/attachment_manager/index.d.ts +2 -2
- package/lib/runtime/attachment_manager/index.js +23 -4
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/helpers.d.ts +3 -2
- package/lib/runtime/helpers.js +36 -1
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +3 -4
- package/lib/runtime/index.js +27 -43
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/command_types.d.ts +10 -9
- package/lib/runtime/parallel/command_types.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +9 -9
- package/lib/runtime/parallel/coordinator.js +62 -55
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -2
- package/lib/runtime/parallel/worker.js +23 -21
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/step_runner.d.ts +3 -3
- package/lib/runtime/step_runner.js +16 -14
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.d.ts +4 -4
- package/lib/runtime/stopwatch.js +21 -2
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +51 -0
- package/lib/runtime/test_case_runner.js +253 -0
- package/lib/runtime/test_case_runner.js.map +1 -0
- package/lib/stack_trace_filter.js +4 -5
- package/lib/stack_trace_filter.js.map +1 -1
- package/lib/step_arguments.d.ts +4 -4
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/build_helpers.js +14 -10
- package/lib/support_code_library_builder/build_helpers.js.map +1 -1
- package/lib/support_code_library_builder/index.d.ts +9 -7
- package/lib/support_code_library_builder/index.js +10 -24
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +22 -23
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/support_code_library_builder/validate_arguments.js +14 -19
- package/lib/support_code_library_builder/validate_arguments.js.map +1 -1
- package/lib/support_code_library_builder/world.d.ts +7 -1
- package/lib/support_code_library_builder/world.js.map +1 -1
- package/lib/time.d.ts +3 -10
- package/lib/time.js +39 -48
- package/lib/time.js.map +1 -1
- package/lib/user_code_runner.js +7 -14
- package/lib/user_code_runner.js.map +1 -1
- package/lib/value_checker.d.ts +2 -2
- package/lib/value_checker.js.map +1 -1
- package/lib/wrapper.mjs +38 -0
- package/package.json +73 -64
- package/CHANGELOG.md +0 -1881
- package/lib/runtime/pickle_runner.d.ts +0 -67
- package/lib/runtime/pickle_runner.js +0 -305
- package/lib/runtime/pickle_runner.js.map +0 -1
- package/lib/status.d.ts +0 -3
- package/lib/status.js +0 -5
- package/lib/status.js.map +0 -1
- package/lib/support_code_library_builder/finalize_helpers.d.ts +0 -10
- package/lib/support_code_library_builder/finalize_helpers.js +0 -26
- package/lib/support_code_library_builder/finalize_helpers.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step_runner.js","sourceRoot":"","sources":["../../src/runtime/step_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
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,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AC,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,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
2
2
|
import { Duration } from 'durations';
|
|
3
3
|
export interface ITestRunStopwatch {
|
|
4
4
|
from: (duration: Duration) => ITestRunStopwatch;
|
|
5
5
|
start: () => ITestRunStopwatch;
|
|
6
6
|
stop: () => ITestRunStopwatch;
|
|
7
7
|
duration: () => Duration;
|
|
8
|
-
timestamp: () => messages.
|
|
8
|
+
timestamp: () => messages.Timestamp;
|
|
9
9
|
}
|
|
10
10
|
export declare class RealTestRunStopwatch implements ITestRunStopwatch {
|
|
11
11
|
private readonly stopwatch;
|
|
@@ -14,7 +14,7 @@ export declare class RealTestRunStopwatch implements ITestRunStopwatch {
|
|
|
14
14
|
start(): ITestRunStopwatch;
|
|
15
15
|
stop(): ITestRunStopwatch;
|
|
16
16
|
duration(): Duration;
|
|
17
|
-
timestamp(): messages.
|
|
17
|
+
timestamp(): messages.Timestamp;
|
|
18
18
|
}
|
|
19
19
|
export declare class PredictableTestRunStopwatch implements ITestRunStopwatch {
|
|
20
20
|
private count;
|
|
@@ -23,6 +23,6 @@ export declare class PredictableTestRunStopwatch implements ITestRunStopwatch {
|
|
|
23
23
|
start(): ITestRunStopwatch;
|
|
24
24
|
stop(): ITestRunStopwatch;
|
|
25
25
|
duration(): Duration;
|
|
26
|
-
timestamp(): messages.
|
|
26
|
+
timestamp(): messages.Timestamp;
|
|
27
27
|
private convertToTimestamp;
|
|
28
28
|
}
|
package/lib/runtime/stopwatch.js
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
22
|
exports.PredictableTestRunStopwatch = exports.RealTestRunStopwatch = void 0;
|
|
4
|
-
const
|
|
23
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
5
24
|
const durations_1 = require("durations");
|
|
6
25
|
class RealTestRunStopwatch {
|
|
7
26
|
constructor() {
|
|
@@ -28,7 +47,7 @@ class RealTestRunStopwatch {
|
|
|
28
47
|
return current;
|
|
29
48
|
}
|
|
30
49
|
timestamp() {
|
|
31
|
-
return
|
|
50
|
+
return messages.TimeConversion.millisecondsSinceEpochToTimestamp(Date.now());
|
|
32
51
|
}
|
|
33
52
|
}
|
|
34
53
|
exports.RealTestRunStopwatch = RealTestRunStopwatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stopwatch.js","sourceRoot":"","sources":["../../src/runtime/stopwatch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stopwatch.js","sourceRoot":"","sources":["../../src/runtime/stopwatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,yCAAoE;AAUpE,MAAa,oBAAoB;IAAjC;QACmB,cAAS,GA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IAAI,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;SACrD;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,SAAS;QACP,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC9D,IAAI,CAAC,KAAK,EAAE,CAAA;QACZ,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,kFAAkF;IAC1E,kBAAkB,CAAC,QAAkB;QAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;QAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,UAAU,CAAC,CAAA;QACrE,OAAO;YACL,OAAO;YACP,KAAK;SACN,CAAA;IACH,CAAC;CACF;AAxCD,kEAwCC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { stopwatch, Stopwatch, duration, Duration } from 'durations'\n\nexport interface ITestRunStopwatch {\n from: (duration: Duration) => ITestRunStopwatch\n start: () => ITestRunStopwatch\n stop: () => ITestRunStopwatch\n duration: () => Duration\n timestamp: () => messages.Timestamp\n}\n\nexport class RealTestRunStopwatch implements ITestRunStopwatch {\n private readonly stopwatch: Stopwatch = stopwatch()\n private base: Duration = null\n\n from(duration: Duration): ITestRunStopwatch {\n this.base = duration\n return this\n }\n\n start(): ITestRunStopwatch {\n this.stopwatch.start()\n return this\n }\n\n stop(): ITestRunStopwatch {\n this.stopwatch.stop()\n return this\n }\n\n duration(): Duration {\n const current = this.stopwatch.duration()\n if (this.base !== null) {\n return duration(this.base.nanos() + current.nanos())\n }\n return current\n }\n\n timestamp(): messages.Timestamp {\n return messages.TimeConversion.millisecondsSinceEpochToTimestamp(Date.now())\n }\n}\n\nexport class PredictableTestRunStopwatch implements ITestRunStopwatch {\n private count = 0\n private base: Duration = null\n\n from(duration: Duration): ITestRunStopwatch {\n this.base = duration\n return this\n }\n\n start(): ITestRunStopwatch {\n return this\n }\n\n stop(): ITestRunStopwatch {\n return this\n }\n\n duration(): Duration {\n const current = duration(this.count * 1000000)\n if (this.base !== null) {\n return duration(this.base.nanos() + current.nanos())\n }\n return current\n }\n\n timestamp(): messages.Timestamp {\n const fakeTimestamp = this.convertToTimestamp(this.duration())\n this.count++\n return fakeTimestamp\n }\n\n // TODO: Remove. It's impossible to convert timestamps to durations and vice-versa\n private convertToTimestamp(duration: Duration): messages.Timestamp {\n const seconds = Math.floor(duration.seconds())\n const nanos = Math.floor((duration.seconds() - seconds) * 1000000000)\n return {\n seconds,\n nanos,\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as messages from '@cucumber/messages';
|
|
3
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
import { ISupportCodeLibrary, ITestCaseHookParameter } from '../support_code_library_builder/types';
|
|
6
|
+
import TestCaseHookDefinition from '../models/test_case_hook_definition';
|
|
7
|
+
import TestStepHookDefinition from '../models/test_step_hook_definition';
|
|
8
|
+
import { IDefinition } from '../models/definition';
|
|
9
|
+
import { ITestRunStopwatch } from './stopwatch';
|
|
10
|
+
export interface INewTestCaseRunnerOptions {
|
|
11
|
+
eventBroadcaster: EventEmitter;
|
|
12
|
+
stopwatch: ITestRunStopwatch;
|
|
13
|
+
gherkinDocument: messages.GherkinDocument;
|
|
14
|
+
newId: IdGenerator.NewId;
|
|
15
|
+
pickle: messages.Pickle;
|
|
16
|
+
testCase: messages.TestCase;
|
|
17
|
+
retries: number;
|
|
18
|
+
skip: boolean;
|
|
19
|
+
supportCodeLibrary: ISupportCodeLibrary;
|
|
20
|
+
worldParameters: any;
|
|
21
|
+
}
|
|
22
|
+
export default class TestCaseRunner {
|
|
23
|
+
private readonly attachmentManager;
|
|
24
|
+
private currentTestCaseStartedId;
|
|
25
|
+
private currentTestStepId;
|
|
26
|
+
private readonly eventBroadcaster;
|
|
27
|
+
private readonly stopwatch;
|
|
28
|
+
private readonly gherkinDocument;
|
|
29
|
+
private readonly newId;
|
|
30
|
+
private readonly pickle;
|
|
31
|
+
private readonly testCase;
|
|
32
|
+
private readonly maxAttempts;
|
|
33
|
+
private readonly skip;
|
|
34
|
+
private readonly supportCodeLibrary;
|
|
35
|
+
private testStepResults;
|
|
36
|
+
private world;
|
|
37
|
+
private readonly worldParameters;
|
|
38
|
+
constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries, skip, supportCodeLibrary, worldParameters, }: INewTestCaseRunnerOptions);
|
|
39
|
+
resetTestProgressData(): void;
|
|
40
|
+
getBeforeStepHookDefinitions(): TestStepHookDefinition[];
|
|
41
|
+
getAfterStepHookDefinitions(): TestStepHookDefinition[];
|
|
42
|
+
getWorstStepResult(): messages.TestStepResult;
|
|
43
|
+
invokeStep(step: messages.PickleStep, stepDefinition: IDefinition, hookParameter?: any): Promise<messages.TestStepResult>;
|
|
44
|
+
isSkippingSteps(): boolean;
|
|
45
|
+
shouldSkipHook(isBeforeHook: boolean): boolean;
|
|
46
|
+
aroundTestStep(testStepId: string, runStepFn: () => Promise<messages.TestStepResult>): Promise<void>;
|
|
47
|
+
run(): Promise<messages.TestStepResultStatus>;
|
|
48
|
+
runHook(hookDefinition: TestCaseHookDefinition, hookParameter: ITestCaseHookParameter, isBeforeHook: boolean): Promise<messages.TestStepResult>;
|
|
49
|
+
runStepHooks(stepHooks: TestStepHookDefinition[], pickleStep: messages.PickleStep, stepResult?: messages.TestStepResult): Promise<messages.TestStepResult[]>;
|
|
50
|
+
runStep(pickleStep: messages.PickleStep, testStep: messages.TestStep): Promise<messages.TestStepResult>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const helpers_1 = require("./helpers");
|
|
26
|
+
const attachment_manager_1 = __importDefault(require("./attachment_manager"));
|
|
27
|
+
const step_runner_1 = __importDefault(require("./step_runner"));
|
|
28
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
29
|
+
const messages_1 = require("@cucumber/messages");
|
|
30
|
+
const value_checker_1 = require("../value_checker");
|
|
31
|
+
class TestCaseRunner {
|
|
32
|
+
constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries = 0, skip, supportCodeLibrary, worldParameters, }) {
|
|
33
|
+
this.attachmentManager = new attachment_manager_1.default(({ data, media }) => {
|
|
34
|
+
if (value_checker_1.doesNotHaveValue(this.currentTestStepId)) {
|
|
35
|
+
throw new Error('Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.');
|
|
36
|
+
}
|
|
37
|
+
const attachment = {
|
|
38
|
+
attachment: {
|
|
39
|
+
body: data,
|
|
40
|
+
contentEncoding: media.encoding,
|
|
41
|
+
mediaType: media.contentType,
|
|
42
|
+
testCaseStartedId: this.currentTestCaseStartedId,
|
|
43
|
+
testStepId: this.currentTestStepId,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
this.eventBroadcaster.emit('envelope', attachment);
|
|
47
|
+
});
|
|
48
|
+
this.eventBroadcaster = eventBroadcaster;
|
|
49
|
+
this.stopwatch = stopwatch;
|
|
50
|
+
this.gherkinDocument = gherkinDocument;
|
|
51
|
+
this.maxAttempts = 1 + (skip ? 0 : retries);
|
|
52
|
+
this.newId = newId;
|
|
53
|
+
this.pickle = pickle;
|
|
54
|
+
this.testCase = testCase;
|
|
55
|
+
this.skip = skip;
|
|
56
|
+
this.supportCodeLibrary = supportCodeLibrary;
|
|
57
|
+
this.worldParameters = worldParameters;
|
|
58
|
+
this.resetTestProgressData();
|
|
59
|
+
}
|
|
60
|
+
resetTestProgressData() {
|
|
61
|
+
this.world = new this.supportCodeLibrary.World({
|
|
62
|
+
attach: this.attachmentManager.create.bind(this.attachmentManager),
|
|
63
|
+
log: this.attachmentManager.log.bind(this.attachmentManager),
|
|
64
|
+
parameters: this.worldParameters,
|
|
65
|
+
});
|
|
66
|
+
this.testStepResults = [];
|
|
67
|
+
}
|
|
68
|
+
getBeforeStepHookDefinitions() {
|
|
69
|
+
return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
|
|
70
|
+
}
|
|
71
|
+
getAfterStepHookDefinitions() {
|
|
72
|
+
return this.supportCodeLibrary.afterTestStepHookDefinitions
|
|
73
|
+
.slice(0)
|
|
74
|
+
.reverse()
|
|
75
|
+
.filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
|
|
76
|
+
}
|
|
77
|
+
getWorstStepResult() {
|
|
78
|
+
if (this.testStepResults.length === 0) {
|
|
79
|
+
return {
|
|
80
|
+
status: this.skip
|
|
81
|
+
? messages.TestStepResultStatus.SKIPPED
|
|
82
|
+
: messages.TestStepResultStatus.PASSED,
|
|
83
|
+
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return messages_1.getWorstTestStepResult(this.testStepResults);
|
|
87
|
+
}
|
|
88
|
+
async invokeStep(step, stepDefinition, hookParameter) {
|
|
89
|
+
return await step_runner_1.default.run({
|
|
90
|
+
defaultTimeout: this.supportCodeLibrary.defaultTimeout,
|
|
91
|
+
hookParameter,
|
|
92
|
+
step,
|
|
93
|
+
stepDefinition,
|
|
94
|
+
world: this.world,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
isSkippingSteps() {
|
|
98
|
+
return (this.getWorstStepResult().status !== messages.TestStepResultStatus.PASSED);
|
|
99
|
+
}
|
|
100
|
+
shouldSkipHook(isBeforeHook) {
|
|
101
|
+
return this.skip || (this.isSkippingSteps() && isBeforeHook);
|
|
102
|
+
}
|
|
103
|
+
async aroundTestStep(testStepId, runStepFn) {
|
|
104
|
+
const testStepStarted = {
|
|
105
|
+
testStepStarted: {
|
|
106
|
+
testCaseStartedId: this.currentTestCaseStartedId,
|
|
107
|
+
testStepId,
|
|
108
|
+
timestamp: this.stopwatch.timestamp(),
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
this.eventBroadcaster.emit('envelope', testStepStarted);
|
|
112
|
+
this.currentTestStepId = testStepId;
|
|
113
|
+
const testStepResult = await runStepFn();
|
|
114
|
+
this.currentTestStepId = null;
|
|
115
|
+
this.testStepResults.push(testStepResult);
|
|
116
|
+
const testStepFinished = {
|
|
117
|
+
testStepFinished: {
|
|
118
|
+
testCaseStartedId: this.currentTestCaseStartedId,
|
|
119
|
+
testStepId,
|
|
120
|
+
testStepResult,
|
|
121
|
+
timestamp: this.stopwatch.timestamp(),
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
this.eventBroadcaster.emit('envelope', testStepFinished);
|
|
125
|
+
}
|
|
126
|
+
async run() {
|
|
127
|
+
for (let attempt = 0; attempt < this.maxAttempts; attempt++) {
|
|
128
|
+
this.currentTestCaseStartedId = this.newId();
|
|
129
|
+
const testCaseStarted = {
|
|
130
|
+
testCaseStarted: {
|
|
131
|
+
attempt,
|
|
132
|
+
testCaseId: this.testCase.id,
|
|
133
|
+
id: this.currentTestCaseStartedId,
|
|
134
|
+
timestamp: this.stopwatch.timestamp(),
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
this.eventBroadcaster.emit('envelope', testCaseStarted);
|
|
138
|
+
// used to determine whether a hook is a Before or After
|
|
139
|
+
let didWeRunStepsYet = false;
|
|
140
|
+
for (const testStep of this.testCase.testSteps) {
|
|
141
|
+
await this.aroundTestStep(testStep.id, async () => {
|
|
142
|
+
if (value_checker_1.doesHaveValue(testStep.hookId)) {
|
|
143
|
+
const hookParameter = {
|
|
144
|
+
gherkinDocument: this.gherkinDocument,
|
|
145
|
+
pickle: this.pickle,
|
|
146
|
+
testCaseStartedId: this.currentTestCaseStartedId,
|
|
147
|
+
};
|
|
148
|
+
if (didWeRunStepsYet) {
|
|
149
|
+
hookParameter.result = this.getWorstStepResult();
|
|
150
|
+
}
|
|
151
|
+
return await this.runHook(findHookDefinition(testStep.hookId, this.supportCodeLibrary), hookParameter, !didWeRunStepsYet);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
const pickleStep = this.pickle.steps.find((pickleStep) => pickleStep.id === testStep.pickleStepId);
|
|
155
|
+
const testStepResult = await this.runStep(pickleStep, testStep);
|
|
156
|
+
didWeRunStepsYet = true;
|
|
157
|
+
return testStepResult;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const willBeRetried = this.getWorstStepResult().status ===
|
|
162
|
+
messages.TestStepResultStatus.FAILED && attempt + 1 < this.maxAttempts;
|
|
163
|
+
const testCaseFinished = {
|
|
164
|
+
testCaseFinished: {
|
|
165
|
+
testCaseStartedId: this.currentTestCaseStartedId,
|
|
166
|
+
timestamp: this.stopwatch.timestamp(),
|
|
167
|
+
willBeRetried,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
this.eventBroadcaster.emit('envelope', testCaseFinished);
|
|
171
|
+
if (!willBeRetried) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
this.resetTestProgressData();
|
|
175
|
+
}
|
|
176
|
+
return this.getWorstStepResult().status;
|
|
177
|
+
}
|
|
178
|
+
async runHook(hookDefinition, hookParameter, isBeforeHook) {
|
|
179
|
+
if (this.shouldSkipHook(isBeforeHook)) {
|
|
180
|
+
return {
|
|
181
|
+
status: messages.TestStepResultStatus.SKIPPED,
|
|
182
|
+
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
return await this.invokeStep(null, hookDefinition, hookParameter);
|
|
186
|
+
}
|
|
187
|
+
async runStepHooks(stepHooks, pickleStep, stepResult) {
|
|
188
|
+
const stepHooksResult = [];
|
|
189
|
+
const hookParameter = {
|
|
190
|
+
gherkinDocument: this.gherkinDocument,
|
|
191
|
+
pickle: this.pickle,
|
|
192
|
+
pickleStep,
|
|
193
|
+
testCaseStartedId: this.currentTestCaseStartedId,
|
|
194
|
+
testStepId: this.currentTestStepId,
|
|
195
|
+
result: stepResult,
|
|
196
|
+
};
|
|
197
|
+
for (const stepHookDefinition of stepHooks) {
|
|
198
|
+
stepHooksResult.push(await this.invokeStep(null, stepHookDefinition, hookParameter));
|
|
199
|
+
}
|
|
200
|
+
return stepHooksResult;
|
|
201
|
+
}
|
|
202
|
+
async runStep(pickleStep, testStep) {
|
|
203
|
+
const stepDefinitions = testStep.stepDefinitionIds.map((stepDefinitionId) => {
|
|
204
|
+
return findStepDefinition(stepDefinitionId, this.supportCodeLibrary);
|
|
205
|
+
});
|
|
206
|
+
if (stepDefinitions.length === 0) {
|
|
207
|
+
return {
|
|
208
|
+
status: messages.TestStepResultStatus.UNDEFINED,
|
|
209
|
+
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else if (stepDefinitions.length > 1) {
|
|
213
|
+
return {
|
|
214
|
+
message: helpers_1.getAmbiguousStepException(stepDefinitions),
|
|
215
|
+
status: messages.TestStepResultStatus.AMBIGUOUS,
|
|
216
|
+
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
else if (this.isSkippingSteps()) {
|
|
220
|
+
return {
|
|
221
|
+
status: messages.TestStepResultStatus.SKIPPED,
|
|
222
|
+
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
let stepResult;
|
|
226
|
+
let stepResults = await this.runStepHooks(this.getBeforeStepHookDefinitions(), pickleStep);
|
|
227
|
+
if (messages_1.getWorstTestStepResult(stepResults).status !==
|
|
228
|
+
messages.TestStepResultStatus.FAILED) {
|
|
229
|
+
stepResult = await this.invokeStep(pickleStep, stepDefinitions[0]);
|
|
230
|
+
stepResults.push(stepResult);
|
|
231
|
+
}
|
|
232
|
+
const afterStepHookResults = await this.runStepHooks(this.getAfterStepHookDefinitions(), pickleStep, stepResult);
|
|
233
|
+
stepResults = stepResults.concat(afterStepHookResults);
|
|
234
|
+
const finalStepResult = messages_1.getWorstTestStepResult(stepResults);
|
|
235
|
+
let finalDuration = messages.TimeConversion.millisecondsToDuration(0);
|
|
236
|
+
for (const result of stepResults) {
|
|
237
|
+
finalDuration = messages.TimeConversion.addDurations(finalDuration, result.duration);
|
|
238
|
+
}
|
|
239
|
+
finalStepResult.duration = finalDuration;
|
|
240
|
+
return finalStepResult;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
exports.default = TestCaseRunner;
|
|
244
|
+
function findHookDefinition(id, supportCodeLibrary) {
|
|
245
|
+
return [
|
|
246
|
+
...supportCodeLibrary.beforeTestCaseHookDefinitions,
|
|
247
|
+
...supportCodeLibrary.afterTestCaseHookDefinitions,
|
|
248
|
+
].find((definition) => definition.id === id);
|
|
249
|
+
}
|
|
250
|
+
function findStepDefinition(id, supportCodeLibrary) {
|
|
251
|
+
return supportCodeLibrary.stepDefinitions.find((definition) => definition.id === id);
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=test_case_runner.js.map
|
|
@@ -0,0 +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;AACtC,6DAA8C;AAC9C,iDAAwE;AAUxE,oDAAkE;AAiBlE,MAAqB,cAAc;IAiBjC,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,GAAG,CAAC,EACX,IAAI,EACJ,kBAAkB,EAClB,eAAe,GACW;QAC1B,IAAI,CAAC,iBAAiB,GAAG,IAAI,4BAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;YACjE,IAAI,gCAAgB,CAAC,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;QACpD,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G,WAAW,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;QAEtD,MAAM,eAAe,GAAG,iCAAsB,CAAC,WAAW,CAAC,CAAA;QAC3D,IAAI,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAA;QACrE,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE;YAChC,aAAa,GAAG,QAAQ,CAAC,cAAc,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;AAxSD,iCAwSC;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 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 }\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 const willBeRetried =\n this.getWorstStepResult().status ===\n messages.TestStepResultStatus.FAILED && attempt + 1 < this.maxAttempts\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"]}
|
|
@@ -4,14 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isFileNameInCucumber = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
7
|
const stack_chain_1 = __importDefault(require("stack-chain"));
|
|
9
8
|
const path_1 = __importDefault(require("path"));
|
|
10
9
|
const value_checker_1 = require("./value_checker");
|
|
11
10
|
const projectRootPath = path_1.default.join(__dirname, '..');
|
|
12
11
|
const projectChildDirs = ['src', 'lib', 'node_modules'];
|
|
13
12
|
function isFileNameInCucumber(fileName) {
|
|
14
|
-
return
|
|
13
|
+
return projectChildDirs.some((dir) => fileName.startsWith(path_1.default.join(projectRootPath, dir)));
|
|
15
14
|
}
|
|
16
15
|
exports.isFileNameInCucumber = isFileNameInCucumber;
|
|
17
16
|
class StackTraceFilter {
|
|
@@ -20,7 +19,7 @@ class StackTraceFilter {
|
|
|
20
19
|
if (this.isErrorInCucumber(frames)) {
|
|
21
20
|
return frames;
|
|
22
21
|
}
|
|
23
|
-
const index =
|
|
22
|
+
const index = frames.findIndex((x) => this.isFrameInCucumber(x));
|
|
24
23
|
if (index === -1) {
|
|
25
24
|
return frames;
|
|
26
25
|
}
|
|
@@ -28,7 +27,7 @@ class StackTraceFilter {
|
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
29
|
isErrorInCucumber(frames) {
|
|
31
|
-
const filteredFrames =
|
|
30
|
+
const filteredFrames = frames.filter((x) => !this.isFrameInNode(x));
|
|
32
31
|
return (filteredFrames.length > 0 && this.isFrameInCucumber(filteredFrames[0]));
|
|
33
32
|
}
|
|
34
33
|
isFrameInCucumber(frame) {
|
|
@@ -37,7 +36,7 @@ class StackTraceFilter {
|
|
|
37
36
|
}
|
|
38
37
|
isFrameInNode(frame) {
|
|
39
38
|
const fileName = value_checker_1.valueOrDefault(frame.getFileName(), '');
|
|
40
|
-
return !
|
|
39
|
+
return !fileName.includes(path_1.default.sep);
|
|
41
40
|
}
|
|
42
41
|
unfilter() {
|
|
43
42
|
stack_chain_1.default.filter.deattach(this.currentFilter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack_trace_filter.js","sourceRoot":"","sources":["../src/stack_trace_filter.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
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,gBAAgB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACnC,QAAQ,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,CACrD,CAAA;AACH,CAAC;AAJD,oDAIC;AAED,MAAqB,gBAAgB;IAGnC,MAAM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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"]}
|
package/lib/step_arguments.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
2
2
|
export interface IPickleStepArgumentFunctionMap<T> {
|
|
3
|
-
dataTable: (arg: messages.
|
|
4
|
-
docString: (arg: messages.
|
|
3
|
+
dataTable: (arg: messages.PickleTable) => T;
|
|
4
|
+
docString: (arg: messages.PickleDocString) => T;
|
|
5
5
|
}
|
|
6
|
-
export declare function parseStepArgument<T>(arg: messages.
|
|
6
|
+
export declare function parseStepArgument<T>(arg: messages.PickleStepArgument, mapping: IPickleStepArgumentFunctionMap<T>): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step_arguments.js","sourceRoot":"","sources":["../src/step_arguments.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAEvB,mDAA+C;AAO/C,SAAgB,iBAAiB,CAC/B,
|
|
1
|
+
{"version":3,"file":"step_arguments.js","sourceRoot":"","sources":["../src/step_arguments.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AAEvB,mDAA+C;AAO/C,SAAgB,iBAAiB,CAC/B,GAAgC,EAChC,OAA0C;IAE1C,IAAI,6BAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;QAChC,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;KACxC;SAAM,IAAI,6BAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;QACvC,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;KACxC;IACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;AAChE,CAAC;AAVD,8CAUC","sourcesContent":["import util from 'util'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue } from './value_checker'\n\nexport interface IPickleStepArgumentFunctionMap<T> {\n dataTable: (arg: messages.PickleTable) => T\n docString: (arg: messages.PickleDocString) => T\n}\n\nexport function parseStepArgument<T>(\n arg: messages.PickleStepArgument,\n mapping: IPickleStepArgumentFunctionMap<T>\n): T {\n if (doesHaveValue(arg.dataTable)) {\n return mapping.dataTable(arg.dataTable)\n } else if (doesHaveValue(arg.docString)) {\n return mapping.docString(arg.docString)\n }\n throw new Error(`Unknown step argument: ${util.inspect(arg)}`)\n}\n"]}
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.buildParameterType = exports.getDefinitionLineAndUri = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
7
|
const cucumber_expressions_1 = require("@cucumber/cucumber-expressions");
|
|
9
8
|
const path_1 = __importDefault(require("path"));
|
|
10
9
|
const stacktrace_js_1 = __importDefault(require("stacktrace-js"));
|
|
@@ -13,17 +12,22 @@ const value_checker_1 = require("../value_checker");
|
|
|
13
12
|
function getDefinitionLineAndUri(cwd) {
|
|
14
13
|
let line;
|
|
15
14
|
let uri;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
try {
|
|
16
|
+
const stackframes = stacktrace_js_1.default.getSync();
|
|
17
|
+
const stackframe = stackframes.find((frame) => {
|
|
18
|
+
return !stack_trace_filter_1.isFileNameInCucumber(frame.getFileName());
|
|
19
|
+
});
|
|
20
|
+
if (stackframe != null) {
|
|
21
|
+
line = stackframe.getLineNumber();
|
|
22
|
+
uri = stackframe.getFileName();
|
|
23
|
+
if (value_checker_1.doesHaveValue(uri)) {
|
|
24
|
+
uri = path_1.default.relative(cwd, uri);
|
|
25
|
+
}
|
|
25
26
|
}
|
|
26
27
|
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.warn('Warning: unable to get definition line and uri', e);
|
|
30
|
+
}
|
|
27
31
|
return {
|
|
28
32
|
line: value_checker_1.valueOrDefault(line, 0),
|
|
29
33
|
uri: value_checker_1.valueOrDefault(uri, 'unknown'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_helpers.js","sourceRoot":"","sources":["../../src/support_code_library_builder/build_helpers.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"build_helpers.js","sourceRoot":"","sources":["../../src/support_code_library_builder/build_helpers.ts"],"names":[],"mappings":";;;;;;AAAA,yEAA8D;AAC9D,gDAAuB;AACvB,k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BC","sourcesContent":["import { ParameterType } from '@cucumber/cucumber-expressions'\nimport path from 'path'\nimport StackTrace from 'stacktrace-js'\nimport { isFileNameInCucumber } from '../stack_trace_filter'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport { ILineAndUri } from '../types'\nimport { IParameterTypeDefinition } from './types'\n\nexport function getDefinitionLineAndUri(cwd: string): ILineAndUri {\n let line: number\n let uri: string\n try {\n const stackframes = StackTrace.getSync()\n const stackframe = stackframes.find((frame) => {\n return !isFileNameInCucumber(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 } catch (e) {\n console.warn('Warning: unable to get definition line and uri', e)\n }\n return {\n line: valueOrDefault(line, 0),\n uri: valueOrDefault(uri, 'unknown'),\n }\n}\n\nexport function buildParameterType({\n name,\n regexp,\n transformer,\n useForSnippets,\n preferForRegexpMatch,\n}: IParameterTypeDefinition<any>): ParameterType<any> {\n if (typeof useForSnippets !== 'boolean') useForSnippets = true\n if (typeof preferForRegexpMatch !== 'boolean') preferForRegexpMatch = false\n return new ParameterType(\n name,\n regexp,\n null,\n transformer,\n useForSnippets,\n preferForRegexpMatch\n )\n}\n"]}
|