@cucumber/cucumber 7.3.2 → 8.0.0-rc.3
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 +88 -51
- package/api/index.d.ts +6 -0
- package/lib/api/convert_configuration.d.ts +4 -0
- package/lib/api/convert_configuration.js +64 -0
- package/lib/api/convert_configuration.js.map +1 -0
- package/lib/api/environment.d.ts +2 -0
- package/lib/api/environment.js +13 -0
- package/lib/api/environment.js.map +1 -0
- package/lib/api/formatters.d.ts +16 -0
- package/lib/api/formatters.js +72 -0
- package/lib/api/formatters.js.map +1 -0
- package/lib/api/gherkin.d.ts +21 -0
- package/lib/api/gherkin.js +65 -0
- package/lib/api/gherkin.js.map +1 -0
- package/lib/api/index.d.ts +11 -0
- package/lib/api/index.js +24 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/load_configuration.d.ts +9 -0
- package/lib/api/load_configuration.js +32 -0
- package/lib/api/load_configuration.js.map +1 -0
- package/lib/api/load_sources.d.ts +9 -0
- package/lib/api/load_sources.js +53 -0
- package/lib/api/load_sources.js.map +1 -0
- package/lib/api/load_support.d.ts +10 -0
- package/lib/api/load_support.js +28 -0
- package/lib/api/load_support.js.map +1 -0
- package/lib/api/paths.d.ts +7 -0
- package/lib/api/paths.js +99 -0
- package/lib/api/paths.js.map +1 -0
- package/lib/api/run_cucumber.d.ts +11 -0
- package/lib/api/run_cucumber.js +108 -0
- package/lib/api/run_cucumber.js.map +1 -0
- package/lib/api/runtime.d.ts +20 -0
- package/lib/api/runtime.js +36 -0
- package/lib/api/runtime.js.map +1 -0
- package/lib/api/support.d.ts +9 -0
- package/lib/api/support.js +21 -0
- package/lib/api/support.js.map +1 -0
- package/lib/api/types.d.ts +168 -0
- package/lib/api/types.js +3 -0
- package/lib/api/types.js.map +1 -0
- package/lib/api/wrapper.mjs +6 -0
- package/lib/cli/helpers.d.ts +16 -9
- package/lib/cli/helpers.js +49 -32
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/i18n.js +7 -7
- package/lib/cli/i18n.js.map +1 -1
- package/lib/cli/index.d.ts +6 -23
- package/lib/cli/index.js +38 -197
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/install_validator.js +1 -1
- package/lib/cli/install_validator.js.map +1 -1
- package/lib/cli/publish_banner.js +6 -6
- package/lib/cli/publish_banner.js.map +1 -1
- package/lib/cli/run.js +15 -7
- package/lib/cli/run.js.map +1 -1
- package/lib/cli/validate_node_engine_version.d.ts +7 -0
- package/lib/cli/validate_node_engine_version.js +20 -0
- package/lib/cli/validate_node_engine_version.js.map +1 -0
- package/lib/configuration/argv_parser.d.ts +20 -0
- package/lib/{cli → configuration}/argv_parser.js +52 -53
- package/lib/configuration/argv_parser.js.map +1 -0
- package/lib/configuration/check_schema.d.ts +2 -0
- package/lib/configuration/check_schema.js +56 -0
- package/lib/configuration/check_schema.js.map +1 -0
- package/lib/configuration/default_configuration.d.ts +2 -0
- package/lib/configuration/default_configuration.js +27 -0
- package/lib/configuration/default_configuration.js.map +1 -0
- package/lib/configuration/from_file.d.ts +2 -0
- package/lib/configuration/from_file.js +68 -0
- package/lib/configuration/from_file.js.map +1 -0
- package/lib/configuration/helpers.d.ts +1 -0
- package/lib/configuration/helpers.js +11 -0
- package/lib/configuration/helpers.js.map +1 -0
- package/lib/configuration/index.d.ts +7 -0
- package/lib/configuration/index.js +25 -0
- package/lib/configuration/index.js.map +1 -0
- package/lib/configuration/locate_file.d.ts +1 -0
- package/lib/configuration/locate_file.js +19 -0
- package/lib/configuration/locate_file.js.map +1 -0
- package/lib/configuration/merge_configurations.d.ts +2 -0
- package/lib/configuration/merge_configurations.js +48 -0
- package/lib/configuration/merge_configurations.js.map +1 -0
- package/lib/configuration/option_splitter.d.ts +3 -0
- package/lib/{cli → configuration}/option_splitter.js +3 -2
- package/lib/configuration/option_splitter.js.map +1 -0
- package/lib/configuration/types.d.ts +25 -0
- package/lib/configuration/types.js +3 -0
- package/lib/configuration/types.js.map +1 -0
- package/lib/configuration/validate_configuration.d.ts +2 -0
- package/lib/configuration/validate_configuration.js +10 -0
- package/lib/configuration/validate_configuration.js.map +1 -0
- package/lib/formatter/builder.d.ts +7 -7
- package/lib/formatter/builder.js +48 -55
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/get_color_fns.js +15 -16
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +2 -1
- package/lib/formatter/helpers/event_data_collector.js +16 -15
- 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.js +29 -42
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +4 -4
- package/lib/formatter/helpers/issue_helpers.js +8 -9
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/keyword_type.js +2 -6
- package/lib/formatter/helpers/keyword_type.js.map +1 -1
- package/lib/formatter/helpers/location_helpers.js +1 -1
- package/lib/formatter/helpers/location_helpers.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.js +9 -18
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.js +8 -7
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +2 -2
- package/lib/formatter/helpers/test_case_attempt_formatter.js +20 -19
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -2
- package/lib/formatter/helpers/test_case_attempt_parser.js +18 -21
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.d.ts +1 -2
- package/lib/formatter/helpers/usage_helpers/index.js +29 -43
- 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 +5 -4
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/http_stream.js +7 -7
- package/lib/formatter/http_stream.js.map +1 -1
- package/lib/formatter/index.d.ts +15 -2
- package/lib/formatter/index.js +2 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +1 -0
- package/lib/formatter/json_formatter.js +25 -20
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.d.ts +1 -0
- package/lib/formatter/message_formatter.js +1 -0
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +1 -0
- package/lib/formatter/progress_bar_formatter.js +18 -17
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +1 -0
- package/lib/formatter/progress_formatter.js +3 -2
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/publish.d.ts +1 -0
- package/lib/formatter/publish.js +5 -0
- package/lib/formatter/publish.js.map +1 -0
- package/lib/formatter/rerun_formatter.d.ts +1 -0
- package/lib/formatter/rerun_formatter.js +15 -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 +3 -3
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.js +2 -2
- 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 +1 -0
- package/lib/formatter/summary_formatter.js +11 -11
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.d.ts +1 -0
- package/lib/formatter/usage_formatter.js +9 -10
- 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 +3 -3
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/importer.js +13 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +9 -1
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.js +9 -7
- package/lib/models/data_table.js.map +1 -1
- package/lib/models/pickle_order.d.ts +1 -0
- package/lib/models/pickle_order.js +3 -0
- package/lib/models/pickle_order.js.map +1 -0
- package/lib/models/step_definition.js +4 -5
- package/lib/models/step_definition.js.map +1 -1
- package/lib/pickle_filter.js +13 -13
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/assemble_test_cases.js +3 -3
- package/lib/runtime/assemble_test_cases.js.map +1 -1
- package/lib/runtime/attachment_manager/index.js +4 -4
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/helpers.d.ts +1 -0
- package/lib/runtime/helpers.js +42 -4
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +7 -7
- package/lib/runtime/index.js +12 -65
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/command_types.d.ts +3 -2
- package/lib/runtime/parallel/command_types.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +32 -12
- package/lib/runtime/parallel/coordinator.js +82 -38
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/run_worker.js +1 -1
- package/lib/runtime/parallel/run_worker.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -4
- package/lib/runtime/parallel/worker.js +18 -33
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/run_test_run_hooks.d.ts +3 -0
- package/lib/runtime/run_test_run_hooks.js +28 -0
- package/lib/runtime/run_test_run_hooks.js.map +1 -0
- package/lib/runtime/step_runner.js +5 -7
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.js +4 -4
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +3 -3
- package/lib/runtime/test_case_runner.js +19 -28
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/stack_trace_filter.js +6 -7
- package/lib/stack_trace_filter.js.map +1 -1
- package/lib/step_arguments.js +2 -2
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/{build_helpers.d.ts → build_parameter_type.d.ts} +0 -2
- package/lib/support_code_library_builder/build_parameter_type.js +13 -0
- package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js +30 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
- package/lib/support_code_library_builder/index.d.ts +4 -2
- package/lib/support_code_library_builder/index.js +43 -34
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
- package/lib/support_code_library_builder/types.d.ts +10 -0
- 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/time.d.ts +1 -0
- package/lib/time.js +17 -2
- package/lib/time.js.map +1 -1
- package/lib/user_code_runner.js +10 -17
- 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/version.d.ts +1 -0
- package/lib/version.js +6 -0
- package/lib/version.js.map +1 -0
- package/lib/wrapper.mjs +42 -0
- package/package.json +98 -70
- package/lib/cli/argv_parser.d.ts +0 -51
- package/lib/cli/argv_parser.js.map +0 -1
- package/lib/cli/configuration_builder.d.ts +0 -46
- package/lib/cli/configuration_builder.js +0 -161
- package/lib/cli/configuration_builder.js.map +0 -1
- package/lib/cli/option_splitter.d.ts +0 -4
- package/lib/cli/option_splitter.js.map +0 -1
- package/lib/cli/profile_loader.d.ts +0 -6
- package/lib/cli/profile_loader.js +0 -42
- package/lib/cli/profile_loader.js.map +0 -1
- package/lib/support_code_library_builder/build_helpers.js +0 -41
- package/lib/support_code_library_builder/build_helpers.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":"worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/worker.ts"],"names":[],"mappings":";;;;;
|
|
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,GA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,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"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import TestRunHookDefinition from '../models/test_run_hook_definition';
|
|
2
|
+
export declare type RunsTestRunHooks = (definitions: TestRunHookDefinition[], name: string) => Promise<void>;
|
|
3
|
+
export declare const makeRunTestRunHooks: (dryRun: boolean, defaultTimeout: number, errorMessage: (name: string, location: string) => string) => RunsTestRunHooks;
|
|
@@ -0,0 +1,28 @@
|
|
|
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.makeRunTestRunHooks = void 0;
|
|
7
|
+
const user_code_runner_1 = __importDefault(require("../user_code_runner"));
|
|
8
|
+
const verror_1 = __importDefault(require("verror"));
|
|
9
|
+
const helpers_1 = require("../formatter/helpers");
|
|
10
|
+
const value_checker_1 = require("../value_checker");
|
|
11
|
+
const makeRunTestRunHooks = (dryRun, defaultTimeout, errorMessage) => dryRun
|
|
12
|
+
? async () => { }
|
|
13
|
+
: async (definitions, name) => {
|
|
14
|
+
for (const hookDefinition of definitions) {
|
|
15
|
+
const { error } = await user_code_runner_1.default.run({
|
|
16
|
+
argsArray: [],
|
|
17
|
+
fn: hookDefinition.code,
|
|
18
|
+
thisArg: null,
|
|
19
|
+
timeoutInMilliseconds: (0, value_checker_1.valueOrDefault)(hookDefinition.options.timeout, defaultTimeout),
|
|
20
|
+
});
|
|
21
|
+
if ((0, value_checker_1.doesHaveValue)(error)) {
|
|
22
|
+
const location = (0, helpers_1.formatLocation)(hookDefinition);
|
|
23
|
+
throw new verror_1.default(error, errorMessage(name, location));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.makeRunTestRunHooks = makeRunTestRunHooks;
|
|
28
|
+
//# sourceMappingURL=run_test_run_hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run_test_run_hooks.js","sourceRoot":"","sources":["../../src/runtime/run_test_run_hooks.ts"],"names":[],"mappings":";;;;;;AAAA,2EAAgD;AAChD,oDAA2B;AAC3B,kDAAqD;AACrD,oDAAgE;AAQzD,MAAM,mBAAmB,GAAG,CACjC,MAAe,EACf,cAAsB,EACtB,YAAwD,EACtC,EAAE,CACpB,MAAM;IACJ,CAAC,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC;IAChB,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;QAC1B,KAAK,MAAM,cAAc,IAAI,WAAW,EAAE;YACxC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,0BAAc,CAAC,GAAG,CAAC;gBACzC,SAAS,EAAE,EAAE;gBACb,EAAE,EAAE,cAAc,CAAC,IAAI;gBACvB,OAAO,EAAE,IAAI;gBACb,qBAAqB,EAAE,IAAA,8BAAc,EACnC,cAAc,CAAC,OAAO,CAAC,OAAO,EAC9B,cAAc,CACf;aACF,CAAC,CAAA;YACF,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,EAAE;gBACxB,MAAM,QAAQ,GAAG,IAAA,wBAAc,EAAC,cAAc,CAAC,CAAA;gBAC/C,MAAM,IAAI,gBAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;aACtD;SACF;IACH,CAAC,CAAA;AAvBM,QAAA,mBAAmB,uBAuBzB","sourcesContent":["import UserCodeRunner from '../user_code_runner'\nimport VError from 'verror'\nimport { formatLocation } from '../formatter/helpers'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\n\nexport type RunsTestRunHooks = (\n definitions: TestRunHookDefinition[],\n name: string\n) => Promise<void>\n\nexport const makeRunTestRunHooks = (\n dryRun: boolean,\n defaultTimeout: number,\n errorMessage: (name: string, location: string) => string\n): RunsTestRunHooks =>\n dryRun\n ? async () => {}\n : async (definitions, name) => {\n for (const hookDefinition of definitions) {\n const { error } = await UserCodeRunner.run({\n argsArray: [],\n fn: hookDefinition.code,\n thisArg: null,\n timeoutInMilliseconds: valueOrDefault(\n hookDefinition.options.timeout,\n defaultTimeout\n ),\n })\n if (doesHaveValue(error)) {\n const location = formatLocation(hookDefinition)\n throw new VError(error, errorMessage(name, location))\n }\n }\n }\n"]}
|
|
@@ -23,7 +23,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.run = void 0;
|
|
26
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
27
26
|
const time_1 = __importDefault(require("../time"));
|
|
28
27
|
const user_code_runner_1 = __importDefault(require("../user_code_runner"));
|
|
29
28
|
const messages = __importStar(require("@cucumber/messages"));
|
|
@@ -43,9 +42,9 @@ async function run({ defaultTimeout, hookParameter, step, stepDefinition, world,
|
|
|
43
42
|
catch (err) {
|
|
44
43
|
error = err;
|
|
45
44
|
}
|
|
46
|
-
if (value_checker_1.doesNotHaveValue(error)) {
|
|
47
|
-
const timeoutInMilliseconds = value_checker_1.valueOrDefault(stepDefinition.options.timeout, defaultTimeout);
|
|
48
|
-
if (
|
|
45
|
+
if ((0, value_checker_1.doesNotHaveValue)(error)) {
|
|
46
|
+
const timeoutInMilliseconds = (0, value_checker_1.valueOrDefault)(stepDefinition.options.timeout, defaultTimeout);
|
|
47
|
+
if (invocationData.validCodeLengths.includes(stepDefinition.code.length)) {
|
|
49
48
|
const data = await user_code_runner_1.default.run({
|
|
50
49
|
argsArray: invocationData.parameters,
|
|
51
50
|
fn: stepDefinition.code,
|
|
@@ -68,8 +67,8 @@ async function run({ defaultTimeout, hookParameter, step, stepDefinition, world,
|
|
|
68
67
|
else if (result === 'pending') {
|
|
69
68
|
status = messages.TestStepResultStatus.PENDING;
|
|
70
69
|
}
|
|
71
|
-
else if (value_checker_1.doesHaveValue(error)) {
|
|
72
|
-
message = assertion_error_formatter_1.format(error);
|
|
70
|
+
else if ((0, value_checker_1.doesHaveValue)(error)) {
|
|
71
|
+
message = (0, assertion_error_formatter_1.format)(error);
|
|
73
72
|
status = messages.TestStepResultStatus.FAILED;
|
|
74
73
|
}
|
|
75
74
|
else {
|
|
@@ -79,7 +78,6 @@ async function run({ defaultTimeout, hookParameter, step, stepDefinition, world,
|
|
|
79
78
|
duration,
|
|
80
79
|
status,
|
|
81
80
|
message,
|
|
82
|
-
willBeRetried: false,
|
|
83
81
|
};
|
|
84
82
|
}
|
|
85
83
|
exports.run = run;
|
|
@@ -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,cAA0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AM,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"]}
|
package/lib/runtime/stopwatch.js
CHANGED
|
@@ -24,7 +24,7 @@ const messages = __importStar(require("@cucumber/messages"));
|
|
|
24
24
|
const durations_1 = require("durations");
|
|
25
25
|
class RealTestRunStopwatch {
|
|
26
26
|
constructor() {
|
|
27
|
-
this.stopwatch = durations_1.stopwatch();
|
|
27
|
+
this.stopwatch = (0, durations_1.stopwatch)();
|
|
28
28
|
this.base = null;
|
|
29
29
|
}
|
|
30
30
|
from(duration) {
|
|
@@ -42,7 +42,7 @@ class RealTestRunStopwatch {
|
|
|
42
42
|
duration() {
|
|
43
43
|
const current = this.stopwatch.duration();
|
|
44
44
|
if (this.base !== null) {
|
|
45
|
-
return durations_1.duration(this.base.nanos() + current.nanos());
|
|
45
|
+
return (0, durations_1.duration)(this.base.nanos() + current.nanos());
|
|
46
46
|
}
|
|
47
47
|
return current;
|
|
48
48
|
}
|
|
@@ -67,9 +67,9 @@ class PredictableTestRunStopwatch {
|
|
|
67
67
|
return this;
|
|
68
68
|
}
|
|
69
69
|
duration() {
|
|
70
|
-
const current = durations_1.duration(this.count * 1000000);
|
|
70
|
+
const current = (0, durations_1.duration)(this.count * 1000000);
|
|
71
71
|
if (this.base !== null) {
|
|
72
|
-
return durations_1.duration(this.base.nanos() + current.nanos());
|
|
72
|
+
return (0, durations_1.duration)(this.base.nanos() + current.nanos());
|
|
73
73
|
}
|
|
74
74
|
return current;
|
|
75
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stopwatch.js","sourceRoot":"","sources":["../../src/runtime/stopwatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,yCAAoE;AAUpE,MAAa,oBAAoB;IAAjC;QACmB,cAAS,GAAc,qBAAS,
|
|
1
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b,CAAC;IAED,QAAQ;QACN,MAAM,OAAO,GAAG,IAAA,oBAAQ,EAAC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,CAAA;QAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;YACtB,OAAO,IAAA,oBAAQ,EAAC,IAAI,CAAC,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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { IdGenerator } from '@cucumber/messages';
|
|
3
2
|
import * as messages from '@cucumber/messages';
|
|
3
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
import { ISupportCodeLibrary, ITestCaseHookParameter } from '../support_code_library_builder/types';
|
|
6
6
|
import TestCaseHookDefinition from '../models/test_case_hook_definition';
|
|
@@ -43,9 +43,9 @@ export default class TestCaseRunner {
|
|
|
43
43
|
invokeStep(step: messages.PickleStep, stepDefinition: IDefinition, hookParameter?: any): Promise<messages.TestStepResult>;
|
|
44
44
|
isSkippingSteps(): boolean;
|
|
45
45
|
shouldSkipHook(isBeforeHook: boolean): boolean;
|
|
46
|
-
aroundTestStep(testStepId: string,
|
|
46
|
+
aroundTestStep(testStepId: string, runStepFn: () => Promise<messages.TestStepResult>): Promise<void>;
|
|
47
47
|
run(): Promise<messages.TestStepResultStatus>;
|
|
48
48
|
runHook(hookDefinition: TestCaseHookDefinition, hookParameter: ITestCaseHookParameter, isBeforeHook: boolean): Promise<messages.TestStepResult>;
|
|
49
|
-
runStepHooks(stepHooks: TestStepHookDefinition[], stepResult?: messages.TestStepResult): Promise<messages.TestStepResult[]>;
|
|
49
|
+
runStepHooks(stepHooks: TestStepHookDefinition[], pickleStep: messages.PickleStep, stepResult?: messages.TestStepResult): Promise<messages.TestStepResult[]>;
|
|
50
50
|
runStep(pickleStep: messages.PickleStep, testStep: messages.TestStep): Promise<messages.TestStepResult>;
|
|
51
51
|
}
|
|
@@ -22,17 +22,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const lodash_1 = require("lodash");
|
|
26
25
|
const helpers_1 = require("./helpers");
|
|
27
26
|
const attachment_manager_1 = __importDefault(require("./attachment_manager"));
|
|
28
27
|
const step_runner_1 = __importDefault(require("./step_runner"));
|
|
29
|
-
const messages_1 = require("@cucumber/messages");
|
|
30
28
|
const messages = __importStar(require("@cucumber/messages"));
|
|
29
|
+
const messages_1 = require("@cucumber/messages");
|
|
31
30
|
const value_checker_1 = require("../value_checker");
|
|
32
31
|
class TestCaseRunner {
|
|
33
32
|
constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, testCase, retries = 0, skip, supportCodeLibrary, worldParameters, }) {
|
|
34
33
|
this.attachmentManager = new attachment_manager_1.default(({ data, media }) => {
|
|
35
|
-
if (value_checker_1.doesNotHaveValue(this.currentTestStepId)) {
|
|
34
|
+
if ((0, value_checker_1.doesNotHaveValue)(this.currentTestStepId)) {
|
|
36
35
|
throw new Error('Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.');
|
|
37
36
|
}
|
|
38
37
|
const attachment = {
|
|
@@ -70,7 +69,8 @@ class TestCaseRunner {
|
|
|
70
69
|
return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
|
|
71
70
|
}
|
|
72
71
|
getAfterStepHookDefinitions() {
|
|
73
|
-
return
|
|
72
|
+
return this.supportCodeLibrary.afterTestStepHookDefinitions
|
|
73
|
+
.slice(0)
|
|
74
74
|
.reverse()
|
|
75
75
|
.filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
|
|
76
76
|
}
|
|
@@ -80,11 +80,10 @@ class TestCaseRunner {
|
|
|
80
80
|
status: this.skip
|
|
81
81
|
? messages.TestStepResultStatus.SKIPPED
|
|
82
82
|
: messages.TestStepResultStatus.PASSED,
|
|
83
|
-
willBeRetried: false,
|
|
84
83
|
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
85
84
|
};
|
|
86
85
|
}
|
|
87
|
-
return messages_1.getWorstTestStepResult(this.testStepResults);
|
|
86
|
+
return (0, messages_1.getWorstTestStepResult)(this.testStepResults);
|
|
88
87
|
}
|
|
89
88
|
async invokeStep(step, stepDefinition, hookParameter) {
|
|
90
89
|
return await step_runner_1.default.run({
|
|
@@ -101,7 +100,7 @@ class TestCaseRunner {
|
|
|
101
100
|
shouldSkipHook(isBeforeHook) {
|
|
102
101
|
return this.skip || (this.isSkippingSteps() && isBeforeHook);
|
|
103
102
|
}
|
|
104
|
-
async aroundTestStep(testStepId,
|
|
103
|
+
async aroundTestStep(testStepId, runStepFn) {
|
|
105
104
|
const testStepStarted = {
|
|
106
105
|
testStepStarted: {
|
|
107
106
|
testCaseStartedId: this.currentTestCaseStartedId,
|
|
@@ -114,14 +113,6 @@ class TestCaseRunner {
|
|
|
114
113
|
const testStepResult = await runStepFn();
|
|
115
114
|
this.currentTestStepId = null;
|
|
116
115
|
this.testStepResults.push(testStepResult);
|
|
117
|
-
if (testStepResult.status === messages.TestStepResultStatus.FAILED &&
|
|
118
|
-
attempt + 1 < this.maxAttempts) {
|
|
119
|
-
/*
|
|
120
|
-
TODO dont rely on `testStepResult.willBeRetried`, it will be moved or removed
|
|
121
|
-
see https://github.com/cucumber/cucumber/issues/902
|
|
122
|
-
*/
|
|
123
|
-
testStepResult.willBeRetried = true;
|
|
124
|
-
}
|
|
125
116
|
const testStepFinished = {
|
|
126
117
|
testStepFinished: {
|
|
127
118
|
testCaseStartedId: this.currentTestCaseStartedId,
|
|
@@ -147,8 +138,8 @@ class TestCaseRunner {
|
|
|
147
138
|
// used to determine whether a hook is a Before or After
|
|
148
139
|
let didWeRunStepsYet = false;
|
|
149
140
|
for (const testStep of this.testCase.testSteps) {
|
|
150
|
-
await this.aroundTestStep(testStep.id,
|
|
151
|
-
if (value_checker_1.doesHaveValue(testStep.hookId)) {
|
|
141
|
+
await this.aroundTestStep(testStep.id, async () => {
|
|
142
|
+
if ((0, value_checker_1.doesHaveValue)(testStep.hookId)) {
|
|
152
143
|
const hookParameter = {
|
|
153
144
|
gherkinDocument: this.gherkinDocument,
|
|
154
145
|
pickle: this.pickle,
|
|
@@ -167,14 +158,17 @@ class TestCaseRunner {
|
|
|
167
158
|
}
|
|
168
159
|
});
|
|
169
160
|
}
|
|
161
|
+
const willBeRetried = this.getWorstStepResult().status ===
|
|
162
|
+
messages.TestStepResultStatus.FAILED && attempt + 1 < this.maxAttempts;
|
|
170
163
|
const testCaseFinished = {
|
|
171
164
|
testCaseFinished: {
|
|
172
165
|
testCaseStartedId: this.currentTestCaseStartedId,
|
|
173
166
|
timestamp: this.stopwatch.timestamp(),
|
|
167
|
+
willBeRetried,
|
|
174
168
|
},
|
|
175
169
|
};
|
|
176
170
|
this.eventBroadcaster.emit('envelope', testCaseFinished);
|
|
177
|
-
if (!
|
|
171
|
+
if (!willBeRetried) {
|
|
178
172
|
break;
|
|
179
173
|
}
|
|
180
174
|
this.resetTestProgressData();
|
|
@@ -186,16 +180,16 @@ class TestCaseRunner {
|
|
|
186
180
|
return {
|
|
187
181
|
status: messages.TestStepResultStatus.SKIPPED,
|
|
188
182
|
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
189
|
-
willBeRetried: false,
|
|
190
183
|
};
|
|
191
184
|
}
|
|
192
185
|
return await this.invokeStep(null, hookDefinition, hookParameter);
|
|
193
186
|
}
|
|
194
|
-
async runStepHooks(stepHooks, stepResult) {
|
|
187
|
+
async runStepHooks(stepHooks, pickleStep, stepResult) {
|
|
195
188
|
const stepHooksResult = [];
|
|
196
189
|
const hookParameter = {
|
|
197
190
|
gherkinDocument: this.gherkinDocument,
|
|
198
191
|
pickle: this.pickle,
|
|
192
|
+
pickleStep,
|
|
199
193
|
testCaseStartedId: this.currentTestCaseStartedId,
|
|
200
194
|
testStepId: this.currentTestStepId,
|
|
201
195
|
result: stepResult,
|
|
@@ -213,34 +207,31 @@ class TestCaseRunner {
|
|
|
213
207
|
return {
|
|
214
208
|
status: messages.TestStepResultStatus.UNDEFINED,
|
|
215
209
|
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
216
|
-
willBeRetried: false,
|
|
217
210
|
};
|
|
218
211
|
}
|
|
219
212
|
else if (stepDefinitions.length > 1) {
|
|
220
213
|
return {
|
|
221
|
-
message: helpers_1.getAmbiguousStepException(stepDefinitions),
|
|
214
|
+
message: (0, helpers_1.getAmbiguousStepException)(stepDefinitions),
|
|
222
215
|
status: messages.TestStepResultStatus.AMBIGUOUS,
|
|
223
216
|
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
224
|
-
willBeRetried: false,
|
|
225
217
|
};
|
|
226
218
|
}
|
|
227
219
|
else if (this.isSkippingSteps()) {
|
|
228
220
|
return {
|
|
229
221
|
status: messages.TestStepResultStatus.SKIPPED,
|
|
230
222
|
duration: messages.TimeConversion.millisecondsToDuration(0),
|
|
231
|
-
willBeRetried: false,
|
|
232
223
|
};
|
|
233
224
|
}
|
|
234
225
|
let stepResult;
|
|
235
|
-
let stepResults = await this.runStepHooks(this.getBeforeStepHookDefinitions());
|
|
236
|
-
if (messages_1.getWorstTestStepResult(stepResults).status !==
|
|
226
|
+
let stepResults = await this.runStepHooks(this.getBeforeStepHookDefinitions(), pickleStep);
|
|
227
|
+
if ((0, messages_1.getWorstTestStepResult)(stepResults).status !==
|
|
237
228
|
messages.TestStepResultStatus.FAILED) {
|
|
238
229
|
stepResult = await this.invokeStep(pickleStep, stepDefinitions[0]);
|
|
239
230
|
stepResults.push(stepResult);
|
|
240
231
|
}
|
|
241
|
-
const afterStepHookResults = await this.runStepHooks(this.getAfterStepHookDefinitions(), stepResult);
|
|
232
|
+
const afterStepHookResults = await this.runStepHooks(this.getAfterStepHookDefinitions(), pickleStep, stepResult);
|
|
242
233
|
stepResults = stepResults.concat(afterStepHookResults);
|
|
243
|
-
const finalStepResult = messages_1.getWorstTestStepResult(stepResults);
|
|
234
|
+
const finalStepResult = (0, messages_1.getWorstTestStepResult)(stepResults);
|
|
244
235
|
let finalDuration = messages.TimeConversion.millisecondsToDuration(0);
|
|
245
236
|
for (const result of stepResults) {
|
|
246
237
|
finalDuration = messages.TimeConversion.addDurations(finalDuration, result.duration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_case_runner.js","sourceRoot":"","sources":["../../src/runtime/test_case_runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA8B;AAC9B,uCAAqD;AACrD,8EAAoD;AACpD,gEAAsC;AACtC,iDAAwE;AACxE,6DAA8C;AAU9C,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,CA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BAAuC;IAEvC,OAAO,kBAAkB,CAAC,eAAe,CAAC,IAAI,CAC5C,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CACrC,CAAA;AACH,CAAC","sourcesContent":["import { clone } from 'lodash'\nimport { getAmbiguousStepException } from './helpers'\nimport AttachmentManager from './attachment_manager'\nimport StepRunner from './step_runner'\nimport { IdGenerator, getWorstTestStepResult } from '@cucumber/messages'\nimport * as messages 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 clone(this.supportCodeLibrary.afterTestStepHookDefinitions)\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 willBeRetried: false,\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 attempt: number,\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 if (\n testStepResult.status === messages.TestStepResultStatus.FAILED &&\n attempt + 1 < this.maxAttempts\n ) {\n /*\n TODO dont rely on `testStepResult.willBeRetried`, it will be moved or removed\n see https://github.com/cucumber/cucumber/issues/902\n */\n testStepResult.willBeRetried = true\n }\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, attempt, 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 testCaseFinished: messages.Envelope = {\n testCaseFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testCaseFinished)\n if (!this.getWorstStepResult().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 willBeRetried: false,\n }\n }\n return await this.invokeStep(null, hookDefinition, hookParameter)\n }\n\n async runStepHooks(\n stepHooks: TestStepHookDefinition[],\n stepResult?: messages.TestStepResult\n ): Promise<messages.TestStepResult[]> {\n const stepHooksResult = []\n const hookParameter: ITestStepHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\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 willBeRetried: false,\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 willBeRetried: false,\n }\n } else if (this.isSkippingSteps()) {\n return {\n status: messages.TestStepResultStatus.SKIPPED,\n duration: messages.TimeConversion.millisecondsToDuration(0),\n willBeRetried: false,\n }\n }\n\n let stepResult\n let stepResults = await this.runStepHooks(\n this.getBeforeStepHookDefinitions()\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 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":";;;;;;;;;;;;;;;;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,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,16 +27,16 @@ 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) {
|
|
35
|
-
const fileName = value_checker_1.valueOrDefault(frame.getFileName(), '');
|
|
34
|
+
const fileName = (0, value_checker_1.valueOrDefault)(frame.getFileName(), '');
|
|
36
35
|
return isFileNameInCucumber(fileName);
|
|
37
36
|
}
|
|
38
37
|
isFrameInNode(frame) {
|
|
39
|
-
const fileName = value_checker_1.valueOrDefault(frame.getFileName(), '');
|
|
40
|
-
return !
|
|
38
|
+
const fileName = (0, value_checker_1.valueOrDefault)(frame.getFileName(), '');
|
|
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;QACJ,IAAI,CAAC,aAAa,GAAG,qBAAU,CAAC,MAAM,CAAC,MAAM,CAC3C,CAAC,IAAS,EAAE,MAAkB,EAAE,EAAE;YAChC,IAAI,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE;gBAClC,OAAO,MAAM,CAAA;aACd;YACD,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;YAChE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;gBAChB,OAAO,MAAM,CAAA;aACd;YACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;QAC/B,CAAC,CACF,CAAA;IACH,CAAC;IAED,iBAAiB,CAAC,MAAkB;QAClC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;QACnE,OAAO,CACL,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CACvE,CAAA;IACH,CAAC;IAED,iBAAiB,CAAC,KAAe;QAC/B,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,KAAK,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAA;QACxD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAA;IACvC,CAAC;IAED,aAAa,CAAC,KAAe;QAC3B,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,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"]}
|
package/lib/step_arguments.js
CHANGED
|
@@ -7,10 +7,10 @@ exports.parseStepArgument = void 0;
|
|
|
7
7
|
const util_1 = __importDefault(require("util"));
|
|
8
8
|
const value_checker_1 = require("./value_checker");
|
|
9
9
|
function parseStepArgument(arg, mapping) {
|
|
10
|
-
if (value_checker_1.doesHaveValue(arg.dataTable)) {
|
|
10
|
+
if ((0, value_checker_1.doesHaveValue)(arg.dataTable)) {
|
|
11
11
|
return mapping.dataTable(arg.dataTable);
|
|
12
12
|
}
|
|
13
|
-
else if (value_checker_1.doesHaveValue(arg.docString)) {
|
|
13
|
+
else if ((0, value_checker_1.doesHaveValue)(arg.docString)) {
|
|
14
14
|
return mapping.docString(arg.docString);
|
|
15
15
|
}
|
|
16
16
|
throw new Error(`Unknown step argument: ${util_1.default.inspect(arg)}`);
|
|
@@ -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,GAAgC,EAChC,OAA0C;IAE1C,IAAI,6BAAa,
|
|
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,IAAA,6BAAa,EAAC,GAAG,CAAC,SAAS,CAAC,EAAE;QAChC,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;KACxC;SAAM,IAAI,IAAA,6BAAa,EAAC,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"]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { ParameterType } from '@cucumber/cucumber-expressions';
|
|
2
|
-
import { ILineAndUri } from '../types';
|
|
3
2
|
import { IParameterTypeDefinition } from './types';
|
|
4
|
-
export declare function getDefinitionLineAndUri(cwd: string): ILineAndUri;
|
|
5
3
|
export declare function buildParameterType({ name, regexp, transformer, useForSnippets, preferForRegexpMatch, }: IParameterTypeDefinition<any>): ParameterType<any>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildParameterType = void 0;
|
|
4
|
+
const cucumber_expressions_1 = require("@cucumber/cucumber-expressions");
|
|
5
|
+
function buildParameterType({ name, regexp, transformer, useForSnippets, preferForRegexpMatch, }) {
|
|
6
|
+
if (typeof useForSnippets !== 'boolean')
|
|
7
|
+
useForSnippets = true;
|
|
8
|
+
if (typeof preferForRegexpMatch !== 'boolean')
|
|
9
|
+
preferForRegexpMatch = false;
|
|
10
|
+
return new cucumber_expressions_1.ParameterType(name, regexp, null, transformer, useForSnippets, preferForRegexpMatch);
|
|
11
|
+
}
|
|
12
|
+
exports.buildParameterType = buildParameterType;
|
|
13
|
+
//# sourceMappingURL=build_parameter_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_parameter_type.js","sourceRoot":"","sources":["../../src/support_code_library_builder/build_parameter_type.ts"],"names":[],"mappings":";;;AAAA,yEAA8D;AAG9D,SAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,MAAM,EACN,WAAW,EACX,cAAc,EACd,oBAAoB,GACU;IAC9B,IAAI,OAAO,cAAc,KAAK,SAAS;QAAE,cAAc,GAAG,IAAI,CAAA;IAC9D,IAAI,OAAO,oBAAoB,KAAK,SAAS;QAAE,oBAAoB,GAAG,KAAK,CAAA;IAC3E,OAAO,IAAI,oCAAa,CACtB,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,WAAW,EACX,cAAc,EACd,oBAAoB,CACrB,CAAA;AACH,CAAC;AAjBD,gDAiBC","sourcesContent":["import { ParameterType } from '@cucumber/cucumber-expressions'\nimport { IParameterTypeDefinition } from './types'\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"]}
|