@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,67 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IdGenerator, messages } from '@cucumber/messages';
|
|
3
|
-
import { EventEmitter } from 'events';
|
|
4
|
-
import { ISupportCodeLibrary, ITestCaseHookParameter } from '../support_code_library_builder/types';
|
|
5
|
-
import TestCaseHookDefinition from '../models/test_case_hook_definition';
|
|
6
|
-
import TestStepHookDefinition from '../models/test_step_hook_definition';
|
|
7
|
-
import StepDefinition from '../models/step_definition';
|
|
8
|
-
import { IDefinition } from '../models/definition';
|
|
9
|
-
import { ITestRunStopwatch } from './stopwatch';
|
|
10
|
-
interface ITestStep {
|
|
11
|
-
id: string;
|
|
12
|
-
isBeforeHook?: boolean;
|
|
13
|
-
isHook: boolean;
|
|
14
|
-
hookDefinition?: TestCaseHookDefinition;
|
|
15
|
-
stepHookDefinition?: TestStepHookDefinition;
|
|
16
|
-
pickleStep?: messages.Pickle.IPickleStep;
|
|
17
|
-
stepDefinitions?: StepDefinition[];
|
|
18
|
-
}
|
|
19
|
-
export interface INewPickleRunnerOptions {
|
|
20
|
-
eventBroadcaster: EventEmitter;
|
|
21
|
-
stopwatch: ITestRunStopwatch;
|
|
22
|
-
gherkinDocument: messages.IGherkinDocument;
|
|
23
|
-
newId: IdGenerator.NewId;
|
|
24
|
-
pickle: messages.IPickle;
|
|
25
|
-
retries: number;
|
|
26
|
-
skip: boolean;
|
|
27
|
-
supportCodeLibrary: ISupportCodeLibrary;
|
|
28
|
-
worldParameters: any;
|
|
29
|
-
}
|
|
30
|
-
export default class PickleRunner {
|
|
31
|
-
private readonly attachmentManager;
|
|
32
|
-
private currentTestCaseStartedId;
|
|
33
|
-
private currentTestStepId;
|
|
34
|
-
private readonly eventBroadcaster;
|
|
35
|
-
private readonly stopwatch;
|
|
36
|
-
private readonly gherkinDocument;
|
|
37
|
-
private readonly newId;
|
|
38
|
-
private readonly pickle;
|
|
39
|
-
private readonly maxAttempts;
|
|
40
|
-
private readonly skip;
|
|
41
|
-
private readonly supportCodeLibrary;
|
|
42
|
-
private readonly testCaseId;
|
|
43
|
-
private readonly testSteps;
|
|
44
|
-
private testStepResults;
|
|
45
|
-
private world;
|
|
46
|
-
private readonly worldParameters;
|
|
47
|
-
constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, retries, skip, supportCodeLibrary, worldParameters, }: INewPickleRunnerOptions);
|
|
48
|
-
resetTestProgressData(): void;
|
|
49
|
-
buildTestSteps(): ITestStep[];
|
|
50
|
-
emitTestCase(): void;
|
|
51
|
-
private mapArgumentGroup;
|
|
52
|
-
getAfterHookDefinitions(): TestCaseHookDefinition[];
|
|
53
|
-
getBeforeHookDefinitions(): TestCaseHookDefinition[];
|
|
54
|
-
getBeforeStepHookDefinitions(): TestStepHookDefinition[];
|
|
55
|
-
getAfterStepHookDefinitions(): TestStepHookDefinition[];
|
|
56
|
-
getStepDefinitions(pickleStep: messages.Pickle.IPickleStep): StepDefinition[];
|
|
57
|
-
getWorstStepResult(): messages.TestStepFinished.ITestStepResult;
|
|
58
|
-
invokeStep(step: messages.Pickle.IPickleStep, stepDefinition: IDefinition, hookParameter?: any): Promise<messages.TestStepFinished.ITestStepResult>;
|
|
59
|
-
isSkippingSteps(): boolean;
|
|
60
|
-
shouldSkipHook(isBeforeHook: boolean): boolean;
|
|
61
|
-
aroundTestStep(testStepId: string, attempt: number, runStepFn: () => Promise<messages.TestStepFinished.ITestStepResult>): Promise<void>;
|
|
62
|
-
run(): Promise<messages.TestStepFinished.TestStepResult.Status>;
|
|
63
|
-
runHook(hookDefinition: TestCaseHookDefinition, hookParameter: ITestCaseHookParameter, isBeforeHook: boolean): Promise<messages.TestStepFinished.ITestStepResult>;
|
|
64
|
-
runStepHooks(stepHooks: TestStepHookDefinition[], stepResult?: messages.TestStepFinished.ITestStepResult): Promise<messages.TestStepFinished.ITestStepResult[]>;
|
|
65
|
-
runStep(testStep: ITestStep): Promise<messages.TestStepFinished.ITestStepResult>;
|
|
66
|
-
}
|
|
67
|
-
export {};
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const lodash_1 = require("lodash");
|
|
7
|
-
const helpers_1 = require("./helpers");
|
|
8
|
-
const attachment_manager_1 = __importDefault(require("./attachment_manager"));
|
|
9
|
-
const step_runner_1 = __importDefault(require("./step_runner"));
|
|
10
|
-
const messages_1 = require("@cucumber/messages");
|
|
11
|
-
const time_1 = require("../time");
|
|
12
|
-
const value_checker_1 = require("../value_checker");
|
|
13
|
-
const query_1 = require("@cucumber/query");
|
|
14
|
-
const { Status } = messages_1.messages.TestStepFinished.TestStepResult;
|
|
15
|
-
class PickleRunner {
|
|
16
|
-
constructor({ eventBroadcaster, stopwatch, gherkinDocument, newId, pickle, retries = 0, skip, supportCodeLibrary, worldParameters, }) {
|
|
17
|
-
this.attachmentManager = new attachment_manager_1.default(({ data, media }) => {
|
|
18
|
-
if (value_checker_1.doesNotHaveValue(this.currentTestStepId)) {
|
|
19
|
-
throw new Error('Cannot attach when a step/hook is not running. Ensure your step/hook waits for the attach to finish.');
|
|
20
|
-
}
|
|
21
|
-
this.eventBroadcaster.emit('envelope', messages_1.messages.Envelope.fromObject({
|
|
22
|
-
attachment: {
|
|
23
|
-
body: data,
|
|
24
|
-
contentEncoding: media.encoding,
|
|
25
|
-
mediaType: media.contentType,
|
|
26
|
-
testCaseStartedId: this.currentTestCaseStartedId,
|
|
27
|
-
testStepId: this.currentTestStepId,
|
|
28
|
-
},
|
|
29
|
-
}));
|
|
30
|
-
});
|
|
31
|
-
this.eventBroadcaster = eventBroadcaster;
|
|
32
|
-
this.stopwatch = stopwatch;
|
|
33
|
-
this.gherkinDocument = gherkinDocument;
|
|
34
|
-
this.maxAttempts = 1 + (skip ? 0 : retries);
|
|
35
|
-
this.newId = newId;
|
|
36
|
-
this.pickle = pickle;
|
|
37
|
-
this.skip = skip;
|
|
38
|
-
this.supportCodeLibrary = supportCodeLibrary;
|
|
39
|
-
this.worldParameters = worldParameters;
|
|
40
|
-
this.testCaseId = this.newId();
|
|
41
|
-
this.testSteps = this.buildTestSteps();
|
|
42
|
-
this.resetTestProgressData();
|
|
43
|
-
}
|
|
44
|
-
resetTestProgressData() {
|
|
45
|
-
this.world = new this.supportCodeLibrary.World({
|
|
46
|
-
attach: this.attachmentManager.create.bind(this.attachmentManager),
|
|
47
|
-
log: this.attachmentManager.log.bind(this.attachmentManager),
|
|
48
|
-
parameters: this.worldParameters,
|
|
49
|
-
});
|
|
50
|
-
this.testStepResults = [];
|
|
51
|
-
}
|
|
52
|
-
buildTestSteps() {
|
|
53
|
-
const testSteps = [];
|
|
54
|
-
this.getBeforeHookDefinitions().forEach((hookDefinition) => {
|
|
55
|
-
testSteps.push({
|
|
56
|
-
id: this.newId(),
|
|
57
|
-
hookDefinition,
|
|
58
|
-
isHook: true,
|
|
59
|
-
isBeforeHook: true,
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
this.pickle.steps.forEach((pickleStep) => {
|
|
63
|
-
const stepDefinitions = this.getStepDefinitions(pickleStep);
|
|
64
|
-
testSteps.push({
|
|
65
|
-
id: this.newId(),
|
|
66
|
-
pickleStep,
|
|
67
|
-
stepDefinitions,
|
|
68
|
-
isHook: false,
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
this.getAfterHookDefinitions().forEach((hookDefinition) => {
|
|
72
|
-
testSteps.push({
|
|
73
|
-
id: this.newId(),
|
|
74
|
-
hookDefinition,
|
|
75
|
-
isHook: true,
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
return testSteps;
|
|
79
|
-
}
|
|
80
|
-
emitTestCase() {
|
|
81
|
-
const testCase = {
|
|
82
|
-
pickleId: this.pickle.id,
|
|
83
|
-
id: this.testCaseId,
|
|
84
|
-
testSteps: this.testSteps.map((testStep) => {
|
|
85
|
-
if (testStep.isHook) {
|
|
86
|
-
return {
|
|
87
|
-
id: testStep.id,
|
|
88
|
-
hookId: testStep.hookDefinition.id,
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
return {
|
|
93
|
-
id: testStep.id,
|
|
94
|
-
pickleStepId: testStep.pickleStep.id,
|
|
95
|
-
stepDefinitionIds: testStep.stepDefinitions.map((x) => x.id),
|
|
96
|
-
stepMatchArgumentsLists: testStep.stepDefinitions.map((x) => {
|
|
97
|
-
const result = x.expression.match(testStep.pickleStep.text);
|
|
98
|
-
return {
|
|
99
|
-
stepMatchArguments: result.map((arg) => {
|
|
100
|
-
return {
|
|
101
|
-
group: this.mapArgumentGroup(arg.group),
|
|
102
|
-
parameterTypeName: arg.parameterType.name,
|
|
103
|
-
};
|
|
104
|
-
}),
|
|
105
|
-
};
|
|
106
|
-
}),
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
};
|
|
111
|
-
this.eventBroadcaster.emit('envelope', messages_1.messages.Envelope.fromObject({ testCase }));
|
|
112
|
-
}
|
|
113
|
-
mapArgumentGroup(group) {
|
|
114
|
-
return {
|
|
115
|
-
start: group.start,
|
|
116
|
-
value: group.value,
|
|
117
|
-
children: value_checker_1.doesHaveValue(group.children)
|
|
118
|
-
? group.children.map((child) => this.mapArgumentGroup(child))
|
|
119
|
-
: undefined,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
getAfterHookDefinitions() {
|
|
123
|
-
return lodash_1.clone(this.supportCodeLibrary.afterTestCaseHookDefinitions)
|
|
124
|
-
.reverse()
|
|
125
|
-
.filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
|
|
126
|
-
}
|
|
127
|
-
getBeforeHookDefinitions() {
|
|
128
|
-
return this.supportCodeLibrary.beforeTestCaseHookDefinitions.filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
|
|
129
|
-
}
|
|
130
|
-
getBeforeStepHookDefinitions() {
|
|
131
|
-
return this.supportCodeLibrary.beforeTestStepHookDefinitions.filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
|
|
132
|
-
}
|
|
133
|
-
getAfterStepHookDefinitions() {
|
|
134
|
-
return lodash_1.clone(this.supportCodeLibrary.afterTestStepHookDefinitions)
|
|
135
|
-
.reverse()
|
|
136
|
-
.filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle));
|
|
137
|
-
}
|
|
138
|
-
getStepDefinitions(pickleStep) {
|
|
139
|
-
return this.supportCodeLibrary.stepDefinitions.filter((stepDefinition) => stepDefinition.matchesStepName(pickleStep.text));
|
|
140
|
-
}
|
|
141
|
-
getWorstStepResult() {
|
|
142
|
-
if (this.testStepResults.length === 0) {
|
|
143
|
-
return messages_1.messages.TestStepFinished.TestStepResult.fromObject({
|
|
144
|
-
status: this.skip ? Status.SKIPPED : Status.PASSED,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return new query_1.Query().getWorstTestStepResult(this.testStepResults);
|
|
148
|
-
}
|
|
149
|
-
async invokeStep(step, stepDefinition, hookParameter) {
|
|
150
|
-
return await step_runner_1.default.run({
|
|
151
|
-
defaultTimeout: this.supportCodeLibrary.defaultTimeout,
|
|
152
|
-
hookParameter,
|
|
153
|
-
step,
|
|
154
|
-
stepDefinition,
|
|
155
|
-
world: this.world,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
isSkippingSteps() {
|
|
159
|
-
return this.getWorstStepResult().status !== Status.PASSED;
|
|
160
|
-
}
|
|
161
|
-
shouldSkipHook(isBeforeHook) {
|
|
162
|
-
return this.skip || (this.isSkippingSteps() && isBeforeHook);
|
|
163
|
-
}
|
|
164
|
-
async aroundTestStep(testStepId, attempt, runStepFn) {
|
|
165
|
-
this.eventBroadcaster.emit('envelope', messages_1.messages.Envelope.fromObject({
|
|
166
|
-
testStepStarted: {
|
|
167
|
-
testCaseStartedId: this.currentTestCaseStartedId,
|
|
168
|
-
testStepId,
|
|
169
|
-
timestamp: this.stopwatch.timestamp(),
|
|
170
|
-
},
|
|
171
|
-
}));
|
|
172
|
-
this.currentTestStepId = testStepId;
|
|
173
|
-
const testStepResult = await runStepFn();
|
|
174
|
-
this.currentTestStepId = null;
|
|
175
|
-
this.testStepResults.push(testStepResult);
|
|
176
|
-
if (testStepResult.status === Status.FAILED &&
|
|
177
|
-
attempt + 1 < this.maxAttempts) {
|
|
178
|
-
/*
|
|
179
|
-
TODO dont rely on `testStepResult.willBeRetried`, it will be moved or removed
|
|
180
|
-
see https://github.com/cucumber/cucumber/issues/902
|
|
181
|
-
*/
|
|
182
|
-
testStepResult.willBeRetried = true;
|
|
183
|
-
}
|
|
184
|
-
this.eventBroadcaster.emit('envelope', messages_1.messages.Envelope.fromObject({
|
|
185
|
-
testStepFinished: {
|
|
186
|
-
testCaseStartedId: this.currentTestCaseStartedId,
|
|
187
|
-
testStepId,
|
|
188
|
-
testStepResult,
|
|
189
|
-
timestamp: this.stopwatch.timestamp(),
|
|
190
|
-
},
|
|
191
|
-
}));
|
|
192
|
-
}
|
|
193
|
-
async run() {
|
|
194
|
-
this.emitTestCase();
|
|
195
|
-
for (let attempt = 0; attempt < this.maxAttempts; attempt++) {
|
|
196
|
-
this.currentTestCaseStartedId = this.newId();
|
|
197
|
-
this.eventBroadcaster.emit('envelope', messages_1.messages.Envelope.fromObject({
|
|
198
|
-
testCaseStarted: {
|
|
199
|
-
attempt,
|
|
200
|
-
testCaseId: this.testCaseId,
|
|
201
|
-
id: this.currentTestCaseStartedId,
|
|
202
|
-
timestamp: this.stopwatch.timestamp(),
|
|
203
|
-
},
|
|
204
|
-
}));
|
|
205
|
-
for (const testStep of this.testSteps) {
|
|
206
|
-
await this.aroundTestStep(testStep.id, attempt, async () => {
|
|
207
|
-
if (testStep.isHook) {
|
|
208
|
-
const hookParameter = {
|
|
209
|
-
gherkinDocument: this.gherkinDocument,
|
|
210
|
-
pickle: this.pickle,
|
|
211
|
-
testCaseStartedId: this.currentTestCaseStartedId,
|
|
212
|
-
};
|
|
213
|
-
if (!testStep.isBeforeHook) {
|
|
214
|
-
hookParameter.result = this.getWorstStepResult();
|
|
215
|
-
}
|
|
216
|
-
return await this.runHook(testStep.hookDefinition, hookParameter, testStep.isBeforeHook);
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
return await this.runStep(testStep);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
this.eventBroadcaster.emit('envelope', messages_1.messages.Envelope.fromObject({
|
|
224
|
-
testCaseFinished: {
|
|
225
|
-
testCaseStartedId: this.currentTestCaseStartedId,
|
|
226
|
-
timestamp: this.stopwatch.timestamp(),
|
|
227
|
-
},
|
|
228
|
-
}));
|
|
229
|
-
if (!this.getWorstStepResult().willBeRetried) {
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
this.resetTestProgressData();
|
|
233
|
-
}
|
|
234
|
-
return this.getWorstStepResult().status;
|
|
235
|
-
}
|
|
236
|
-
async runHook(hookDefinition, hookParameter, isBeforeHook) {
|
|
237
|
-
if (this.shouldSkipHook(isBeforeHook)) {
|
|
238
|
-
return messages_1.messages.TestStepFinished.TestStepResult.fromObject({
|
|
239
|
-
status: Status.SKIPPED,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
return await this.invokeStep(null, hookDefinition, hookParameter);
|
|
243
|
-
}
|
|
244
|
-
async runStepHooks(stepHooks, stepResult) {
|
|
245
|
-
const stepHooksResult = [];
|
|
246
|
-
const hookParameter = {
|
|
247
|
-
gherkinDocument: this.gherkinDocument,
|
|
248
|
-
pickle: this.pickle,
|
|
249
|
-
testCaseStartedId: this.currentTestCaseStartedId,
|
|
250
|
-
testStepId: this.currentTestStepId,
|
|
251
|
-
result: stepResult,
|
|
252
|
-
};
|
|
253
|
-
for (const stepHookDefinition of stepHooks) {
|
|
254
|
-
stepHooksResult.push(await this.invokeStep(null, stepHookDefinition, hookParameter));
|
|
255
|
-
}
|
|
256
|
-
return stepHooksResult;
|
|
257
|
-
}
|
|
258
|
-
async runStep(testStep) {
|
|
259
|
-
if (testStep.stepDefinitions.length === 0) {
|
|
260
|
-
return messages_1.messages.TestStepFinished.TestStepResult.fromObject({
|
|
261
|
-
status: Status.UNDEFINED,
|
|
262
|
-
duration: {
|
|
263
|
-
seconds: '0',
|
|
264
|
-
nanos: 0,
|
|
265
|
-
},
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
else if (testStep.stepDefinitions.length > 1) {
|
|
269
|
-
return messages_1.messages.TestStepFinished.TestStepResult.fromObject({
|
|
270
|
-
message: helpers_1.getAmbiguousStepException(testStep.stepDefinitions),
|
|
271
|
-
status: Status.AMBIGUOUS,
|
|
272
|
-
duration: {
|
|
273
|
-
seconds: '0',
|
|
274
|
-
nanos: 0,
|
|
275
|
-
},
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
else if (this.isSkippingSteps()) {
|
|
279
|
-
return messages_1.messages.TestStepFinished.TestStepResult.fromObject({
|
|
280
|
-
status: Status.SKIPPED,
|
|
281
|
-
duration: {
|
|
282
|
-
seconds: '0',
|
|
283
|
-
nanos: 0,
|
|
284
|
-
},
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
let stepResult;
|
|
288
|
-
let stepResults = await this.runStepHooks(this.getBeforeStepHookDefinitions(), stepResult);
|
|
289
|
-
if (new query_1.Query().getWorstTestStepResult(stepResults).status !== Status.FAILED) {
|
|
290
|
-
stepResult = await this.invokeStep(testStep.pickleStep, testStep.stepDefinitions[0]);
|
|
291
|
-
stepResults.push(stepResult);
|
|
292
|
-
}
|
|
293
|
-
const afterStepHookResults = await this.runStepHooks(this.getAfterStepHookDefinitions(), stepResult);
|
|
294
|
-
stepResults = stepResults.concat(afterStepHookResults);
|
|
295
|
-
const finalStepResult = new query_1.Query().getWorstTestStepResult(stepResults);
|
|
296
|
-
let finalDuration = time_1.getZeroDuration();
|
|
297
|
-
for (const result of stepResults) {
|
|
298
|
-
finalDuration = time_1.addDurations(finalDuration, result.duration);
|
|
299
|
-
}
|
|
300
|
-
finalStepResult.duration = finalDuration;
|
|
301
|
-
return finalStepResult;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
exports.default = PickleRunner;
|
|
305
|
-
//# sourceMappingURL=pickle_runner.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pickle_runner.js","sourceRoot":"","sources":["../../src/runtime/pickle_runner.ts"],"names":[],"mappings":";;;;;AAAA,mCAA8B;AAC9B,uCAAqD;AACrD,8EAAoD;AACpD,gEAAsC;AACtC,iDAA0D;AAC1D,kCAAuD;AAWvD,oDAAkE;AAGlE,2CAAuC;AAEvC,MAAM,EAAE,MAAM,EAAE,GAAG,mBAAQ,CAAC,gBAAgB,CAAC,cAAc,CAAA;AAwB3D,MAAqB,YAAY;IAkB/B,YAAY,EACV,gBAAgB,EAChB,SAAS,EACT,eA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,GAAG,aAAa,CAAA;QACxC,OAAO,eAAe,CAAA;IACxB,CAAC;CACF;AA7YD,+BA6YC","sourcesContent":["import { clone } from 'lodash'\nimport { getAmbiguousStepException } from './helpers'\nimport AttachmentManager from './attachment_manager'\nimport StepRunner from './step_runner'\nimport { IdGenerator, messages } from '@cucumber/messages'\nimport { addDurations, getZeroDuration } from '../time'\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 StepDefinition from '../models/step_definition'\nimport { IDefinition } from '../models/definition'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { ITestRunStopwatch } from './stopwatch'\nimport { Group } from '@cucumber/cucumber-expressions'\nimport { Query } from '@cucumber/query'\n\nconst { Status } = messages.TestStepFinished.TestStepResult\n\ninterface ITestStep {\n id: string\n isBeforeHook?: boolean\n isHook: boolean\n hookDefinition?: TestCaseHookDefinition\n stepHookDefinition?: TestStepHookDefinition\n pickleStep?: messages.Pickle.IPickleStep\n stepDefinitions?: StepDefinition[]\n}\n\nexport interface INewPickleRunnerOptions {\n eventBroadcaster: EventEmitter\n stopwatch: ITestRunStopwatch\n gherkinDocument: messages.IGherkinDocument\n newId: IdGenerator.NewId\n pickle: messages.IPickle\n retries: number\n skip: boolean\n supportCodeLibrary: ISupportCodeLibrary\n worldParameters: any\n}\n\nexport default class PickleRunner {\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.IGherkinDocument\n private readonly newId: IdGenerator.NewId\n private readonly pickle: messages.IPickle\n private readonly maxAttempts: number\n private readonly skip: boolean\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private readonly testCaseId: string\n private readonly testSteps: ITestStep[]\n private testStepResults: messages.TestStepFinished.ITestStepResult[]\n private world: any\n private readonly worldParameters: any\n\n constructor({\n eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId,\n pickle,\n retries = 0,\n skip,\n supportCodeLibrary,\n worldParameters,\n }: INewPickleRunnerOptions) {\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 this.eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n attachment: {\n body: data,\n contentEncoding: media.encoding,\n mediaType: media.contentType,\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId: this.currentTestStepId,\n },\n })\n )\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.skip = skip\n this.supportCodeLibrary = supportCodeLibrary\n this.worldParameters = worldParameters\n this.testCaseId = this.newId()\n this.testSteps = this.buildTestSteps()\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 buildTestSteps(): ITestStep[] {\n const testSteps: ITestStep[] = []\n this.getBeforeHookDefinitions().forEach((hookDefinition) => {\n testSteps.push({\n id: this.newId(),\n hookDefinition,\n isHook: true,\n isBeforeHook: true,\n })\n })\n this.pickle.steps.forEach((pickleStep) => {\n const stepDefinitions = this.getStepDefinitions(pickleStep)\n testSteps.push({\n id: this.newId(),\n pickleStep,\n stepDefinitions,\n isHook: false,\n })\n })\n this.getAfterHookDefinitions().forEach((hookDefinition) => {\n testSteps.push({\n id: this.newId(),\n hookDefinition,\n isHook: true,\n })\n })\n return testSteps\n }\n\n emitTestCase(): void {\n const testCase = {\n pickleId: this.pickle.id,\n id: this.testCaseId,\n testSteps: this.testSteps.map((testStep) => {\n if (testStep.isHook) {\n return {\n id: testStep.id,\n hookId: testStep.hookDefinition.id,\n }\n } else {\n return {\n id: testStep.id,\n pickleStepId: testStep.pickleStep.id,\n stepDefinitionIds: testStep.stepDefinitions.map((x) => x.id),\n stepMatchArgumentsLists: testStep.stepDefinitions.map((x) => {\n const result = x.expression.match(testStep.pickleStep.text)\n return {\n stepMatchArguments: result.map((arg) => {\n return {\n group: this.mapArgumentGroup(arg.group),\n parameterTypeName: arg.parameterType.name,\n }\n }),\n }\n }),\n }\n }\n }),\n }\n this.eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({ testCase })\n )\n }\n\n private mapArgumentGroup(\n group: Group\n ): messages.TestCase.TestStep.StepMatchArgumentsList.StepMatchArgument.IGroup {\n return {\n start: group.start,\n value: group.value,\n children: doesHaveValue(group.children)\n ? group.children.map((child) => this.mapArgumentGroup(child))\n : undefined,\n }\n }\n\n getAfterHookDefinitions(): TestCaseHookDefinition[] {\n return clone(this.supportCodeLibrary.afterTestCaseHookDefinitions)\n .reverse()\n .filter((hookDefinition) => hookDefinition.appliesToTestCase(this.pickle))\n }\n\n getBeforeHookDefinitions(): TestCaseHookDefinition[] {\n return this.supportCodeLibrary.beforeTestCaseHookDefinitions.filter(\n (hookDefinition) => hookDefinition.appliesToTestCase(this.pickle)\n )\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 getStepDefinitions(\n pickleStep: messages.Pickle.IPickleStep\n ): StepDefinition[] {\n return this.supportCodeLibrary.stepDefinitions.filter((stepDefinition) =>\n stepDefinition.matchesStepName(pickleStep.text)\n )\n }\n\n getWorstStepResult(): messages.TestStepFinished.ITestStepResult {\n if (this.testStepResults.length === 0) {\n return messages.TestStepFinished.TestStepResult.fromObject({\n status: this.skip ? Status.SKIPPED : Status.PASSED,\n })\n }\n return new Query().getWorstTestStepResult(this.testStepResults)\n }\n\n async invokeStep(\n step: messages.Pickle.IPickleStep,\n stepDefinition: IDefinition,\n hookParameter?: any\n ): Promise<messages.TestStepFinished.ITestStepResult> {\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 this.getWorstStepResult().status !== Status.PASSED\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.TestStepFinished.ITestStepResult>\n ): Promise<void> {\n this.eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n testStepStarted: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n timestamp: this.stopwatch.timestamp(),\n },\n })\n )\n this.currentTestStepId = testStepId\n const testStepResult = await runStepFn()\n this.currentTestStepId = null\n this.testStepResults.push(testStepResult)\n if (\n testStepResult.status === Status.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 this.eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n testStepFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n testStepId,\n testStepResult,\n timestamp: this.stopwatch.timestamp(),\n },\n })\n )\n }\n\n async run(): Promise<messages.TestStepFinished.TestStepResult.Status> {\n this.emitTestCase()\n for (let attempt = 0; attempt < this.maxAttempts; attempt++) {\n this.currentTestCaseStartedId = this.newId()\n this.eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n testCaseStarted: {\n attempt,\n testCaseId: this.testCaseId,\n id: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n },\n })\n )\n for (const testStep of this.testSteps) {\n await this.aroundTestStep(testStep.id, attempt, async () => {\n if (testStep.isHook) {\n const hookParameter: ITestCaseHookParameter = {\n gherkinDocument: this.gherkinDocument,\n pickle: this.pickle,\n testCaseStartedId: this.currentTestCaseStartedId,\n }\n if (!testStep.isBeforeHook) {\n hookParameter.result = this.getWorstStepResult()\n }\n return await this.runHook(\n testStep.hookDefinition,\n hookParameter,\n testStep.isBeforeHook\n )\n } else {\n return await this.runStep(testStep)\n }\n })\n }\n this.eventBroadcaster.emit(\n 'envelope',\n messages.Envelope.fromObject({\n testCaseFinished: {\n testCaseStartedId: this.currentTestCaseStartedId,\n timestamp: this.stopwatch.timestamp(),\n },\n })\n )\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.TestStepFinished.ITestStepResult> {\n if (this.shouldSkipHook(isBeforeHook)) {\n return messages.TestStepFinished.TestStepResult.fromObject({\n status: Status.SKIPPED,\n })\n }\n return await this.invokeStep(null, hookDefinition, hookParameter)\n }\n\n async runStepHooks(\n stepHooks: TestStepHookDefinition[],\n stepResult?: messages.TestStepFinished.ITestStepResult\n ): Promise<messages.TestStepFinished.ITestStepResult[]> {\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 testStep: ITestStep\n ): Promise<messages.TestStepFinished.ITestStepResult> {\n if (testStep.stepDefinitions.length === 0) {\n return messages.TestStepFinished.TestStepResult.fromObject({\n status: Status.UNDEFINED,\n duration: {\n seconds: '0',\n nanos: 0,\n },\n })\n } else if (testStep.stepDefinitions.length > 1) {\n return messages.TestStepFinished.TestStepResult.fromObject({\n message: getAmbiguousStepException(testStep.stepDefinitions),\n status: Status.AMBIGUOUS,\n duration: {\n seconds: '0',\n nanos: 0,\n },\n })\n } else if (this.isSkippingSteps()) {\n return messages.TestStepFinished.TestStepResult.fromObject({\n status: Status.SKIPPED,\n duration: {\n seconds: '0',\n nanos: 0,\n },\n })\n }\n\n let stepResult\n let stepResults = await this.runStepHooks(\n this.getBeforeStepHookDefinitions(),\n stepResult\n )\n if (\n new Query().getWorstTestStepResult(stepResults).status !== Status.FAILED\n ) {\n stepResult = await this.invokeStep(\n testStep.pickleStep,\n testStep.stepDefinitions[0]\n )\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 = new Query().getWorstTestStepResult(stepResults)\n let finalDuration = getZeroDuration()\n for (const result of stepResults) {\n finalDuration = addDurations(finalDuration, result.duration)\n }\n finalStepResult.duration = finalDuration\n return finalStepResult\n }\n}\n"]}
|
package/lib/status.d.ts
DELETED
package/lib/status.js
DELETED
package/lib/status.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":";;AAAA,iDAA6C;AAE7C,kBAAe,mBAAQ,CAAC,gBAAgB,CAAC,cAAc,CAAC,MAAM,CAAA","sourcesContent":["import { messages } from '@cucumber/messages'\n\nexport default messages.TestStepFinished.TestStepResult.Status\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export interface IDefinitionConfig {
|
|
2
|
-
code: any;
|
|
3
|
-
line: number;
|
|
4
|
-
uri: string;
|
|
5
|
-
}
|
|
6
|
-
export interface IValidateNoGeneratorFunctionsRequest {
|
|
7
|
-
cwd: string;
|
|
8
|
-
definitionConfigs: IDefinitionConfig[];
|
|
9
|
-
}
|
|
10
|
-
export declare function validateNoGeneratorFunctions({ cwd, definitionConfigs, }: IValidateNoGeneratorFunctionsRequest): void;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateNoGeneratorFunctions = void 0;
|
|
7
|
-
const is_generator_1 = __importDefault(require("is-generator"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
function validateNoGeneratorFunctions({ cwd, definitionConfigs, }) {
|
|
10
|
-
const generatorDefinitionConfigs = definitionConfigs.filter((definitionConfig) => is_generator_1.default.fn(definitionConfig.code));
|
|
11
|
-
if (generatorDefinitionConfigs.length > 0) {
|
|
12
|
-
const references = generatorDefinitionConfigs
|
|
13
|
-
.map((definitionConfig) => `${path_1.default.relative(cwd, definitionConfig.uri)}:${definitionConfig.line.toString()}`)
|
|
14
|
-
.join('\n ');
|
|
15
|
-
const message = `
|
|
16
|
-
The following hook/step definitions use generator functions:
|
|
17
|
-
|
|
18
|
-
${references}
|
|
19
|
-
|
|
20
|
-
Use 'this.setDefinitionFunctionWrapper(fn)' to wrap them in a function that returns a promise.
|
|
21
|
-
`;
|
|
22
|
-
throw new Error(message);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.validateNoGeneratorFunctions = validateNoGeneratorFunctions;
|
|
26
|
-
//# sourceMappingURL=finalize_helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"finalize_helpers.js","sourceRoot":"","sources":["../../src/support_code_library_builder/finalize_helpers.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAsC;AACtC,gDAAuB;AAavB,SAAgB,4BAA4B,CAAC,EAC3C,GAAG,EACH,iBAAiB,GACoB;IACrC,MAAM,0BAA0B,GAAG,iBAAiB,CAAC,MAAM,CACzD,CAAC,gBAAgB,EAAE,EAAE,CAAC,sBAAW,CAAC,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAC5D,CAAA;IACD,IAAI,0BAA0B,CAAC,MAAM,GAAG,CAAC,EAAE;QACzC,MAAM,UAAU,GAAG,0BAA0B;aAC1C,GAAG,CACF,CAAC,gBAAgB,EAAE,EAAE,CACnB,GAAG,cAAI,CAAC,QAAQ,CACd,GAAG,EACH,gBAAgB,CAAC,GAAG,CACrB,IAAI,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAC1C;aACA,IAAI,CAAC,MAAM,CAAC,CAAA;QACf,MAAM,OAAO,GAAG;;;UAGV,UAAU;;;OAGb,CAAA;QACH,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;KACzB;AACH,CAAC;AA1BD,oEA0BC","sourcesContent":["import isGenerator from 'is-generator'\nimport path from 'path'\n\nexport interface IDefinitionConfig {\n code: any\n line: number\n uri: string\n}\n\nexport interface IValidateNoGeneratorFunctionsRequest {\n cwd: string\n definitionConfigs: IDefinitionConfig[]\n}\n\nexport function validateNoGeneratorFunctions({\n cwd,\n definitionConfigs,\n}: IValidateNoGeneratorFunctionsRequest): void {\n const generatorDefinitionConfigs = definitionConfigs.filter(\n (definitionConfig) => isGenerator.fn(definitionConfig.code)\n )\n if (generatorDefinitionConfigs.length > 0) {\n const references = generatorDefinitionConfigs\n .map(\n (definitionConfig) =>\n `${path.relative(\n cwd,\n definitionConfig.uri\n )}:${definitionConfig.line.toString()}`\n )\n .join('\\n ')\n const message = `\n The following hook/step definitions use generator functions:\n\n ${references}\n\n Use 'this.setDefinitionFunctionWrapper(fn)' to wrap them in a function that returns a promise.\n `\n throw new Error(message)\n }\n}\n"]}
|