@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,9 +1,11 @@
|
|
|
1
|
-
import { IdGenerator
|
|
1
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
2
|
+
import * as messages from '@cucumber/messages';
|
|
2
3
|
import TestCaseHookDefinition from '../models/test_case_hook_definition';
|
|
3
4
|
import TestStepHookDefinition from '../models/test_step_hook_definition';
|
|
4
5
|
import TestRunHookDefinition from '../models/test_run_hook_definition';
|
|
5
6
|
import StepDefinition from '../models/step_definition';
|
|
6
7
|
import { DefineStepPattern, IDefineStepOptions, IDefineSupportCodeMethods, IDefineTestCaseHookOptions, IDefineTestStepHookOptions, IDefineTestRunHookOptions, IParameterTypeDefinition, ISupportCodeLibrary, TestCaseHookFunction, TestStepHookFunction } from './types';
|
|
8
|
+
import { ICanonicalSupportCodeIds } from '../runtime/parallel/command_types';
|
|
7
9
|
interface ITestCaseHookDefinitionConfig {
|
|
8
10
|
code: any;
|
|
9
11
|
line: number;
|
|
@@ -41,21 +43,21 @@ export declare class SupportCodeLibraryBuilder {
|
|
|
41
43
|
constructor();
|
|
42
44
|
defineParameterType(options: IParameterTypeDefinition<any>): void;
|
|
43
45
|
defineStep(pattern: DefineStepPattern, options: IDefineStepOptions | Function, code?: Function): void;
|
|
44
|
-
defineTestCaseHook(getCollection: () => ITestCaseHookDefinitionConfig[]): (options: string | IDefineTestCaseHookOptions | TestCaseHookFunction
|
|
45
|
-
defineTestStepHook(getCollection: () => ITestStepHookDefinitionConfig[]): (options: string | IDefineTestStepHookOptions | TestStepHookFunction
|
|
46
|
+
defineTestCaseHook(getCollection: () => ITestCaseHookDefinitionConfig[]): <WorldType>(options: string | IDefineTestCaseHookOptions | TestCaseHookFunction<WorldType>, code?: TestCaseHookFunction<WorldType>) => void;
|
|
47
|
+
defineTestStepHook(getCollection: () => ITestStepHookDefinitionConfig[]): <WorldType>(options: string | IDefineTestStepHookOptions | TestStepHookFunction<WorldType>, code?: TestStepHookFunction<WorldType>) => void;
|
|
46
48
|
defineTestRunHook(getCollection: () => ITestRunHookDefinitionConfig[]): (options: IDefineTestRunHookOptions | Function, code?: Function) => void;
|
|
47
49
|
wrapCode({ code, wrapperOptions, }: {
|
|
48
50
|
code: Function;
|
|
49
51
|
wrapperOptions: any;
|
|
50
52
|
}): Function;
|
|
51
|
-
buildTestCaseHookDefinitions(configs: ITestCaseHookDefinitionConfig[]): TestCaseHookDefinition[];
|
|
53
|
+
buildTestCaseHookDefinitions(configs: ITestCaseHookDefinitionConfig[], canonicalIds?: string[]): TestCaseHookDefinition[];
|
|
52
54
|
buildTestStepHookDefinitions(configs: ITestStepHookDefinitionConfig[]): TestStepHookDefinition[];
|
|
53
55
|
buildTestRunHookDefinitions(configs: ITestRunHookDefinitionConfig[]): TestRunHookDefinition[];
|
|
54
|
-
buildStepDefinitions(): {
|
|
56
|
+
buildStepDefinitions(canonicalIds?: string[]): {
|
|
55
57
|
stepDefinitions: StepDefinition[];
|
|
56
|
-
undefinedParameterTypes: messages.
|
|
58
|
+
undefinedParameterTypes: messages.UndefinedParameterType[];
|
|
57
59
|
};
|
|
58
|
-
finalize(): ISupportCodeLibrary;
|
|
60
|
+
finalize(canonicalIds?: ICanonicalSupportCodeIds): ISupportCodeLibrary;
|
|
59
61
|
reset(cwd: string, newId: IdGenerator.NewId): void;
|
|
60
62
|
}
|
|
61
63
|
declare const _default: SupportCodeLibraryBuilder;
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SupportCodeLibraryBuilder = exports.builtinParameterTypes = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
7
|
const build_helpers_1 = require("./build_helpers");
|
|
9
8
|
const test_case_hook_definition_1 = __importDefault(require("../models/test_case_hook_definition"));
|
|
10
9
|
const test_step_hook_definition_1 = __importDefault(require("../models/test_step_hook_definition"));
|
|
@@ -15,7 +14,6 @@ const validate_arguments_1 = __importDefault(require("./validate_arguments"));
|
|
|
15
14
|
const util_arity_1 = __importDefault(require("util-arity"));
|
|
16
15
|
const cucumber_expressions_1 = require("@cucumber/cucumber-expressions");
|
|
17
16
|
const value_checker_1 = require("../value_checker");
|
|
18
|
-
const finalize_helpers_1 = require("./finalize_helpers");
|
|
19
17
|
const world_1 = __importDefault(require("./world"));
|
|
20
18
|
exports.builtinParameterTypes = ['int', 'float', 'word', 'string', ''];
|
|
21
19
|
class SupportCodeLibraryBuilder {
|
|
@@ -144,15 +142,15 @@ class SupportCodeLibraryBuilder {
|
|
|
144
142
|
}
|
|
145
143
|
return code;
|
|
146
144
|
}
|
|
147
|
-
buildTestCaseHookDefinitions(configs) {
|
|
148
|
-
return configs.map(({ code, line, options, uri }) => {
|
|
145
|
+
buildTestCaseHookDefinitions(configs, canonicalIds) {
|
|
146
|
+
return configs.map(({ code, line, options, uri }, index) => {
|
|
149
147
|
const wrappedCode = this.wrapCode({
|
|
150
148
|
code,
|
|
151
149
|
wrapperOptions: options.wrapperOptions,
|
|
152
150
|
});
|
|
153
151
|
return new test_case_hook_definition_1.default({
|
|
154
152
|
code: wrappedCode,
|
|
155
|
-
id: this.newId(),
|
|
153
|
+
id: canonicalIds ? canonicalIds[index] : this.newId(),
|
|
156
154
|
line,
|
|
157
155
|
options,
|
|
158
156
|
unwrappedCode: code,
|
|
@@ -192,10 +190,10 @@ class SupportCodeLibraryBuilder {
|
|
|
192
190
|
});
|
|
193
191
|
});
|
|
194
192
|
}
|
|
195
|
-
buildStepDefinitions() {
|
|
193
|
+
buildStepDefinitions(canonicalIds) {
|
|
196
194
|
const stepDefinitions = [];
|
|
197
195
|
const undefinedParameterTypes = [];
|
|
198
|
-
this.stepDefinitionConfigs.forEach(({ code, line, options, pattern, uri }) => {
|
|
196
|
+
this.stepDefinitionConfigs.forEach(({ code, line, options, pattern, uri }, index) => {
|
|
199
197
|
let expression;
|
|
200
198
|
if (typeof pattern === 'string') {
|
|
201
199
|
try {
|
|
@@ -222,7 +220,7 @@ class SupportCodeLibraryBuilder {
|
|
|
222
220
|
stepDefinitions.push(new step_definition_1.default({
|
|
223
221
|
code: wrappedCode,
|
|
224
222
|
expression,
|
|
225
|
-
id: this.newId(),
|
|
223
|
+
id: canonicalIds ? canonicalIds[index] : this.newId(),
|
|
226
224
|
line,
|
|
227
225
|
options,
|
|
228
226
|
pattern,
|
|
@@ -232,25 +230,13 @@ class SupportCodeLibraryBuilder {
|
|
|
232
230
|
});
|
|
233
231
|
return { stepDefinitions, undefinedParameterTypes };
|
|
234
232
|
}
|
|
235
|
-
finalize() {
|
|
236
|
-
|
|
237
|
-
const definitionConfigs = lodash_1.default.chain([
|
|
238
|
-
this.afterTestCaseHookDefinitionConfigs,
|
|
239
|
-
this.afterTestRunHookDefinitionConfigs,
|
|
240
|
-
this.beforeTestCaseHookDefinitionConfigs,
|
|
241
|
-
this.beforeTestRunHookDefinitionConfigs,
|
|
242
|
-
this.stepDefinitionConfigs,
|
|
243
|
-
])
|
|
244
|
-
.flatten()
|
|
245
|
-
.value();
|
|
246
|
-
finalize_helpers_1.validateNoGeneratorFunctions({ cwd: this.cwd, definitionConfigs });
|
|
247
|
-
}
|
|
248
|
-
const stepDefinitionsResult = this.buildStepDefinitions();
|
|
233
|
+
finalize(canonicalIds) {
|
|
234
|
+
const stepDefinitionsResult = this.buildStepDefinitions(canonicalIds === null || canonicalIds === void 0 ? void 0 : canonicalIds.stepDefinitionIds);
|
|
249
235
|
return {
|
|
250
|
-
afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.afterTestCaseHookDefinitionConfigs),
|
|
236
|
+
afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.afterTestCaseHookDefinitionConfigs, canonicalIds === null || canonicalIds === void 0 ? void 0 : canonicalIds.afterTestCaseHookDefinitionIds),
|
|
251
237
|
afterTestRunHookDefinitions: this.buildTestRunHookDefinitions(this.afterTestRunHookDefinitionConfigs),
|
|
252
238
|
afterTestStepHookDefinitions: this.buildTestStepHookDefinitions(this.afterTestStepHookDefinitionConfigs),
|
|
253
|
-
beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.beforeTestCaseHookDefinitionConfigs),
|
|
239
|
+
beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.beforeTestCaseHookDefinitionConfigs, canonicalIds === null || canonicalIds === void 0 ? void 0 : canonicalIds.beforeTestCaseHookDefinitionIds),
|
|
254
240
|
beforeTestRunHookDefinitions: this.buildTestRunHookDefinitions(this.beforeTestRunHookDefinitionConfigs),
|
|
255
241
|
beforeTestStepHookDefinitions: this.buildTestStepHookDefinitions(this.beforeTestStepHookDefinitionConfigs),
|
|
256
242
|
defaultTimeout: this.defaultTimeout,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/support_code_library_builder/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,mDAA6E;AAE7E,oGAAwE;AACxE,oGA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,EAAE,CAAA;QAC7C,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAA;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAC1B,IAAI,CAAC,qBAAqB,GAAG,IAAI,4CAAqB,EAAE,CAAA;QACxD,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAA;QAC/B,IAAI,CAAC,KAAK,GAAG,eAAK,CAAA;IACpB,CAAC;CACF;AAjWD,8DAiWC;AAED,kBAAe,IAAI,yBAAyB,EAAE,CAAA","sourcesContent":["import _ from 'lodash'\nimport { buildParameterType, getDefinitionLineAndUri } from './build_helpers'\nimport { IdGenerator, messages } from '@cucumber/messages'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport StepDefinition from '../models/step_definition'\nimport { formatLocation } from '../formatter/helpers'\nimport validateArguments from './validate_arguments'\nimport arity from 'util-arity'\n\nimport {\n CucumberExpression,\n ParameterTypeRegistry,\n RegularExpression,\n} from '@cucumber/cucumber-expressions'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { validateNoGeneratorFunctions } from './finalize_helpers'\nimport {\n DefineStepPattern,\n IDefineStepOptions,\n IDefineSupportCodeMethods,\n IDefineTestCaseHookOptions,\n IDefineTestStepHookOptions,\n IDefineTestRunHookOptions,\n IParameterTypeDefinition,\n ISupportCodeLibrary,\n TestCaseHookFunction,\n TestStepHookFunction,\n} from './types'\nimport World from './world'\n\ninterface IStepDefinitionConfig {\n code: any\n line: number\n options: any\n pattern: string | RegExp\n uri: string\n}\n\ninterface ITestCaseHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\ninterface ITestStepHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\ninterface ITestRunHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\nexport const builtinParameterTypes = ['int', 'float', 'word', 'string', '']\n\nexport class SupportCodeLibraryBuilder {\n public readonly methods: IDefineSupportCodeMethods\n\n private afterTestCaseHookDefinitionConfigs: ITestCaseHookDefinitionConfig[]\n private afterTestRunHookDefinitionConfigs: ITestRunHookDefinitionConfig[]\n private afterTestStepHookDefinitionConfigs: ITestStepHookDefinitionConfig[]\n private beforeTestCaseHookDefinitionConfigs: ITestCaseHookDefinitionConfig[]\n private beforeTestRunHookDefinitionConfigs: ITestRunHookDefinitionConfig[]\n private beforeTestStepHookDefinitionConfigs: ITestStepHookDefinitionConfig[]\n private cwd: string\n private defaultTimeout: number\n private definitionFunctionWrapper: any\n private newId: IdGenerator.NewId\n private parameterTypeRegistry: ParameterTypeRegistry\n private stepDefinitionConfigs: IStepDefinitionConfig[]\n private World: any\n\n constructor() {\n const defineStep = this.defineStep.bind(this)\n this.methods = {\n After: this.defineTestCaseHook(\n () => this.afterTestCaseHookDefinitionConfigs\n ),\n AfterAll: this.defineTestRunHook(\n () => this.afterTestRunHookDefinitionConfigs\n ),\n AfterStep: this.defineTestStepHook(\n () => this.afterTestStepHookDefinitionConfigs\n ),\n Before: this.defineTestCaseHook(\n () => this.beforeTestCaseHookDefinitionConfigs\n ),\n BeforeAll: this.defineTestRunHook(\n () => this.beforeTestRunHookDefinitionConfigs\n ),\n BeforeStep: this.defineTestStepHook(\n () => this.beforeTestStepHookDefinitionConfigs\n ),\n defineParameterType: this.defineParameterType.bind(this),\n defineStep,\n Given: defineStep,\n setDefaultTimeout: (milliseconds) => {\n this.defaultTimeout = milliseconds\n },\n setDefinitionFunctionWrapper: (fn) => {\n this.definitionFunctionWrapper = fn\n },\n setWorldConstructor: (fn) => {\n this.World = fn\n },\n Then: defineStep,\n When: defineStep,\n }\n }\n\n defineParameterType(options: IParameterTypeDefinition<any>): void {\n const parameterType = buildParameterType(options)\n this.parameterTypeRegistry.defineParameterType(parameterType)\n }\n\n defineStep(\n pattern: DefineStepPattern,\n options: IDefineStepOptions | Function,\n code?: Function\n ): void {\n if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, pattern, options },\n fnName: 'defineStep',\n location: formatLocation({ line, uri }),\n })\n this.stepDefinitionConfigs.push({\n code,\n line,\n options,\n pattern,\n uri,\n })\n }\n\n defineTestCaseHook(\n getCollection: () => ITestCaseHookDefinitionConfig[]\n ): (\n options: string | IDefineTestCaseHookOptions | TestCaseHookFunction,\n code?: TestCaseHookFunction\n ) => void {\n return (\n options: string | IDefineTestCaseHookOptions | TestCaseHookFunction,\n code?: TestCaseHookFunction\n ) => {\n if (typeof options === 'string') {\n options = { tags: options }\n } else if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestCaseHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n defineTestStepHook(\n getCollection: () => ITestStepHookDefinitionConfig[]\n ): (\n options: string | IDefineTestStepHookOptions | TestStepHookFunction,\n code?: TestStepHookFunction\n ) => void {\n return (\n options: string | IDefineTestStepHookOptions | TestStepHookFunction,\n code?: TestStepHookFunction\n ) => {\n if (typeof options === 'string') {\n options = { tags: options }\n } else if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestStepHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n defineTestRunHook(\n getCollection: () => ITestRunHookDefinitionConfig[]\n ): (options: IDefineTestRunHookOptions | Function, code?: Function) => void {\n return (options: IDefineTestRunHookOptions | Function, code?: Function) => {\n if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestRunHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n wrapCode({\n code,\n wrapperOptions,\n }: {\n code: Function\n wrapperOptions: any\n }): Function {\n if (doesHaveValue(this.definitionFunctionWrapper)) {\n const codeLength = code.length\n const wrappedCode = this.definitionFunctionWrapper(code, wrapperOptions)\n if (wrappedCode !== code) {\n return arity(codeLength, wrappedCode)\n }\n return wrappedCode\n }\n return code\n }\n\n buildTestCaseHookDefinitions(\n configs: ITestCaseHookDefinitionConfig[]\n ): TestCaseHookDefinition[] {\n return configs.map(({ code, line, options, uri }) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestCaseHookDefinition({\n code: wrappedCode,\n id: this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildTestStepHookDefinitions(\n configs: ITestStepHookDefinitionConfig[]\n ): TestStepHookDefinition[] {\n return configs.map(({ code, line, options, uri }) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestStepHookDefinition({\n code: wrappedCode,\n id: this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildTestRunHookDefinitions(\n configs: ITestRunHookDefinitionConfig[]\n ): TestRunHookDefinition[] {\n return configs.map(({ code, line, options, uri }) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestRunHookDefinition({\n code: wrappedCode,\n id: this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildStepDefinitions(): {\n stepDefinitions: StepDefinition[]\n undefinedParameterTypes: messages.IUndefinedParameterType[]\n } {\n const stepDefinitions: StepDefinition[] = []\n const undefinedParameterTypes: messages.IUndefinedParameterType[] = []\n this.stepDefinitionConfigs.forEach(\n ({ code, line, options, pattern, uri }) => {\n let expression\n if (typeof pattern === 'string') {\n try {\n expression = new CucumberExpression(\n pattern,\n this.parameterTypeRegistry\n )\n } catch (e) {\n if (doesHaveValue(e.undefinedParameterTypeName)) {\n undefinedParameterTypes.push({\n name: e.undefinedParameterTypeName,\n expression: pattern,\n })\n return\n }\n throw e\n }\n } else {\n expression = new RegularExpression(\n pattern,\n this.parameterTypeRegistry\n )\n }\n\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n stepDefinitions.push(\n new StepDefinition({\n code: wrappedCode,\n expression,\n id: this.newId(),\n line,\n options,\n pattern,\n unwrappedCode: code,\n uri,\n })\n )\n }\n )\n return { stepDefinitions, undefinedParameterTypes }\n }\n\n finalize(): ISupportCodeLibrary {\n if (doesNotHaveValue(this.definitionFunctionWrapper)) {\n const definitionConfigs = _.chain([\n this.afterTestCaseHookDefinitionConfigs,\n this.afterTestRunHookDefinitionConfigs,\n this.beforeTestCaseHookDefinitionConfigs,\n this.beforeTestRunHookDefinitionConfigs,\n this.stepDefinitionConfigs,\n ])\n .flatten()\n .value()\n validateNoGeneratorFunctions({ cwd: this.cwd, definitionConfigs })\n }\n const stepDefinitionsResult = this.buildStepDefinitions()\n return {\n afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(\n this.afterTestCaseHookDefinitionConfigs\n ),\n afterTestRunHookDefinitions: this.buildTestRunHookDefinitions(\n this.afterTestRunHookDefinitionConfigs\n ),\n afterTestStepHookDefinitions: this.buildTestStepHookDefinitions(\n this.afterTestStepHookDefinitionConfigs\n ),\n beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(\n this.beforeTestCaseHookDefinitionConfigs\n ),\n beforeTestRunHookDefinitions: this.buildTestRunHookDefinitions(\n this.beforeTestRunHookDefinitionConfigs\n ),\n beforeTestStepHookDefinitions: this.buildTestStepHookDefinitions(\n this.beforeTestStepHookDefinitionConfigs\n ),\n defaultTimeout: this.defaultTimeout,\n parameterTypeRegistry: this.parameterTypeRegistry,\n undefinedParameterTypes: stepDefinitionsResult.undefinedParameterTypes,\n stepDefinitions: stepDefinitionsResult.stepDefinitions,\n World: this.World,\n }\n }\n\n reset(cwd: string, newId: IdGenerator.NewId): void {\n this.cwd = cwd\n this.newId = newId\n this.afterTestCaseHookDefinitionConfigs = []\n this.afterTestRunHookDefinitionConfigs = []\n this.afterTestStepHookDefinitionConfigs = []\n this.beforeTestCaseHookDefinitionConfigs = []\n this.beforeTestRunHookDefinitionConfigs = []\n this.beforeTestStepHookDefinitionConfigs = []\n this.definitionFunctionWrapper = null\n this.defaultTimeout = 5000\n this.parameterTypeRegistry = new ParameterTypeRegistry()\n this.stepDefinitionConfigs = []\n this.World = World\n }\n}\n\nexport default new SupportCodeLibraryBuilder()\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/support_code_library_builder/index.ts"],"names":[],"mappings":";;;;;;AAAA,mDAA6E;AAG7E,oGAAwE;AACxE,oGAAwE;AACxE,kGAAsE;AACtE,gFAAsD;AACtD,kDAAqD;AACrD,8EAAoD;AACpD,4DAA8B;AAE9B,yEAIuC;AACvC,oDAAgD;AAahD,oDAA2B;AAgCd,QAAA,qBAAqB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAA;AAE3E,MAAa,yBAAyB;IAiBpC;QACE,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC7C,IAAI,CAAC,OAAO,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAC5B,GAAG,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAC9C;YACD,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAC9B,GAAG,EAAE,CAAC,IAAI,CAAC,iCAAiC,CAC7C;YACD,SAAS,EAAE,IAAI,CAAC,kBAAkB,CAChC,GAAG,EAAE,CAAC,IAAI,CAAC,kCAAkC,CAC9C;YACD,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAC7B,GAAG,EAAE,CAAC,IAAI,CAAC,mCAAmC,CAC/C;YACD,SA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B,CAAC,eAAe;YACtD,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,KAAwB;QACzC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAA;QAC5C,IAAI,CAAC,iCAAiC,GAAG,EAAE,CAAA;QAC3C,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAA;QAC5C,IAAI,CAAC,mCAAmC,GAAG,EAAE,CAAA;QAC7C,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAA;QAC5C,IAAI,CAAC,mCAAmC,GAAG,EAAE,CAAA;QAC7C,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAA;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAC1B,IAAI,CAAC,qBAAqB,GAAG,IAAI,4CAAqB,EAAE,CAAA;QACxD,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAA;QAC/B,IAAI,CAAC,KAAK,GAAG,eAAK,CAAA;IACpB,CAAC;CACF;AAtWD,8DAsWC;AAED,kBAAe,IAAI,yBAAyB,EAAE,CAAA","sourcesContent":["import { buildParameterType, getDefinitionLineAndUri } from './build_helpers'\nimport { IdGenerator } from '@cucumber/messages'\nimport * as messages from '@cucumber/messages'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport StepDefinition from '../models/step_definition'\nimport { formatLocation } from '../formatter/helpers'\nimport validateArguments from './validate_arguments'\nimport arity from 'util-arity'\n\nimport {\n CucumberExpression,\n ParameterTypeRegistry,\n RegularExpression,\n} from '@cucumber/cucumber-expressions'\nimport { doesHaveValue } from '../value_checker'\nimport {\n DefineStepPattern,\n IDefineStepOptions,\n IDefineSupportCodeMethods,\n IDefineTestCaseHookOptions,\n IDefineTestStepHookOptions,\n IDefineTestRunHookOptions,\n IParameterTypeDefinition,\n ISupportCodeLibrary,\n TestCaseHookFunction,\n TestStepHookFunction,\n} from './types'\nimport World from './world'\nimport { ICanonicalSupportCodeIds } from '../runtime/parallel/command_types'\n\ninterface IStepDefinitionConfig {\n code: any\n line: number\n options: any\n pattern: string | RegExp\n uri: string\n}\n\ninterface ITestCaseHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\ninterface ITestStepHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\ninterface ITestRunHookDefinitionConfig {\n code: any\n line: number\n options: any\n uri: string\n}\n\nexport const builtinParameterTypes = ['int', 'float', 'word', 'string', '']\n\nexport class SupportCodeLibraryBuilder {\n public readonly methods: IDefineSupportCodeMethods\n\n private afterTestCaseHookDefinitionConfigs: ITestCaseHookDefinitionConfig[]\n private afterTestRunHookDefinitionConfigs: ITestRunHookDefinitionConfig[]\n private afterTestStepHookDefinitionConfigs: ITestStepHookDefinitionConfig[]\n private beforeTestCaseHookDefinitionConfigs: ITestCaseHookDefinitionConfig[]\n private beforeTestRunHookDefinitionConfigs: ITestRunHookDefinitionConfig[]\n private beforeTestStepHookDefinitionConfigs: ITestStepHookDefinitionConfig[]\n private cwd: string\n private defaultTimeout: number\n private definitionFunctionWrapper: any\n private newId: IdGenerator.NewId\n private parameterTypeRegistry: ParameterTypeRegistry\n private stepDefinitionConfigs: IStepDefinitionConfig[]\n private World: any\n\n constructor() {\n const defineStep = this.defineStep.bind(this)\n this.methods = {\n After: this.defineTestCaseHook(\n () => this.afterTestCaseHookDefinitionConfigs\n ),\n AfterAll: this.defineTestRunHook(\n () => this.afterTestRunHookDefinitionConfigs\n ),\n AfterStep: this.defineTestStepHook(\n () => this.afterTestStepHookDefinitionConfigs\n ),\n Before: this.defineTestCaseHook(\n () => this.beforeTestCaseHookDefinitionConfigs\n ),\n BeforeAll: this.defineTestRunHook(\n () => this.beforeTestRunHookDefinitionConfigs\n ),\n BeforeStep: this.defineTestStepHook(\n () => this.beforeTestStepHookDefinitionConfigs\n ),\n defineParameterType: this.defineParameterType.bind(this),\n defineStep,\n Given: defineStep,\n setDefaultTimeout: (milliseconds) => {\n this.defaultTimeout = milliseconds\n },\n setDefinitionFunctionWrapper: (fn) => {\n this.definitionFunctionWrapper = fn\n },\n setWorldConstructor: (fn) => {\n this.World = fn\n },\n Then: defineStep,\n When: defineStep,\n }\n }\n\n defineParameterType(options: IParameterTypeDefinition<any>): void {\n const parameterType = buildParameterType(options)\n this.parameterTypeRegistry.defineParameterType(parameterType)\n }\n\n defineStep(\n pattern: DefineStepPattern,\n options: IDefineStepOptions | Function,\n code?: Function\n ): void {\n if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, pattern, options },\n fnName: 'defineStep',\n location: formatLocation({ line, uri }),\n })\n this.stepDefinitionConfigs.push({\n code,\n line,\n options,\n pattern,\n uri,\n })\n }\n\n defineTestCaseHook(\n getCollection: () => ITestCaseHookDefinitionConfig[]\n ): <WorldType>(\n options:\n | string\n | IDefineTestCaseHookOptions\n | TestCaseHookFunction<WorldType>,\n code?: TestCaseHookFunction<WorldType>\n ) => void {\n return <WorldType>(\n options:\n | string\n | IDefineTestCaseHookOptions\n | TestCaseHookFunction<WorldType>,\n code?: TestCaseHookFunction<WorldType>\n ) => {\n if (typeof options === 'string') {\n options = { tags: options }\n } else if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestCaseHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n defineTestStepHook(\n getCollection: () => ITestStepHookDefinitionConfig[]\n ): <WorldType>(\n options:\n | string\n | IDefineTestStepHookOptions\n | TestStepHookFunction<WorldType>,\n code?: TestStepHookFunction<WorldType>\n ) => void {\n return <WorldType>(\n options:\n | string\n | IDefineTestStepHookOptions\n | TestStepHookFunction<WorldType>,\n code?: TestStepHookFunction<WorldType>\n ) => {\n if (typeof options === 'string') {\n options = { tags: options }\n } else if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestStepHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n defineTestRunHook(\n getCollection: () => ITestRunHookDefinitionConfig[]\n ): (options: IDefineTestRunHookOptions | Function, code?: Function) => void {\n return (options: IDefineTestRunHookOptions | Function, code?: Function) => {\n if (typeof options === 'function') {\n code = options\n options = {}\n }\n const { line, uri } = getDefinitionLineAndUri(this.cwd)\n validateArguments({\n args: { code, options },\n fnName: 'defineTestRunHook',\n location: formatLocation({ line, uri }),\n })\n getCollection().push({\n code,\n line,\n options,\n uri,\n })\n }\n }\n\n wrapCode({\n code,\n wrapperOptions,\n }: {\n code: Function\n wrapperOptions: any\n }): Function {\n if (doesHaveValue(this.definitionFunctionWrapper)) {\n const codeLength = code.length\n const wrappedCode = this.definitionFunctionWrapper(code, wrapperOptions)\n if (wrappedCode !== code) {\n return arity(codeLength, wrappedCode)\n }\n return wrappedCode\n }\n return code\n }\n\n buildTestCaseHookDefinitions(\n configs: ITestCaseHookDefinitionConfig[],\n canonicalIds?: string[]\n ): TestCaseHookDefinition[] {\n return configs.map(({ code, line, options, uri }, index) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestCaseHookDefinition({\n code: wrappedCode,\n id: canonicalIds ? canonicalIds[index] : this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildTestStepHookDefinitions(\n configs: ITestStepHookDefinitionConfig[]\n ): TestStepHookDefinition[] {\n return configs.map(({ code, line, options, uri }) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestStepHookDefinition({\n code: wrappedCode,\n id: this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildTestRunHookDefinitions(\n configs: ITestRunHookDefinitionConfig[]\n ): TestRunHookDefinition[] {\n return configs.map(({ code, line, options, uri }) => {\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n return new TestRunHookDefinition({\n code: wrappedCode,\n id: this.newId(),\n line,\n options,\n unwrappedCode: code,\n uri,\n })\n })\n }\n\n buildStepDefinitions(canonicalIds?: string[]): {\n stepDefinitions: StepDefinition[]\n undefinedParameterTypes: messages.UndefinedParameterType[]\n } {\n const stepDefinitions: StepDefinition[] = []\n const undefinedParameterTypes: messages.UndefinedParameterType[] = []\n this.stepDefinitionConfigs.forEach(\n ({ code, line, options, pattern, uri }, index) => {\n let expression\n if (typeof pattern === 'string') {\n try {\n expression = new CucumberExpression(\n pattern,\n this.parameterTypeRegistry\n )\n } catch (e) {\n if (doesHaveValue(e.undefinedParameterTypeName)) {\n undefinedParameterTypes.push({\n name: e.undefinedParameterTypeName,\n expression: pattern,\n })\n return\n }\n throw e\n }\n } else {\n expression = new RegularExpression(\n pattern,\n this.parameterTypeRegistry\n )\n }\n\n const wrappedCode = this.wrapCode({\n code,\n wrapperOptions: options.wrapperOptions,\n })\n stepDefinitions.push(\n new StepDefinition({\n code: wrappedCode,\n expression,\n id: canonicalIds ? canonicalIds[index] : this.newId(),\n line,\n options,\n pattern,\n unwrappedCode: code,\n uri,\n })\n )\n }\n )\n return { stepDefinitions, undefinedParameterTypes }\n }\n\n finalize(canonicalIds?: ICanonicalSupportCodeIds): ISupportCodeLibrary {\n const stepDefinitionsResult = this.buildStepDefinitions(\n canonicalIds?.stepDefinitionIds\n )\n return {\n afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(\n this.afterTestCaseHookDefinitionConfigs,\n canonicalIds?.afterTestCaseHookDefinitionIds\n ),\n afterTestRunHookDefinitions: this.buildTestRunHookDefinitions(\n this.afterTestRunHookDefinitionConfigs\n ),\n afterTestStepHookDefinitions: this.buildTestStepHookDefinitions(\n this.afterTestStepHookDefinitionConfigs\n ),\n beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(\n this.beforeTestCaseHookDefinitionConfigs,\n canonicalIds?.beforeTestCaseHookDefinitionIds\n ),\n beforeTestRunHookDefinitions: this.buildTestRunHookDefinitions(\n this.beforeTestRunHookDefinitionConfigs\n ),\n beforeTestStepHookDefinitions: this.buildTestStepHookDefinitions(\n this.beforeTestStepHookDefinitionConfigs\n ),\n defaultTimeout: this.defaultTimeout,\n parameterTypeRegistry: this.parameterTypeRegistry,\n undefinedParameterTypes: stepDefinitionsResult.undefinedParameterTypes,\n stepDefinitions: stepDefinitionsResult.stepDefinitions,\n World: this.World,\n }\n }\n\n reset(cwd: string, newId: IdGenerator.NewId): void {\n this.cwd = cwd\n this.newId = newId\n this.afterTestCaseHookDefinitionConfigs = []\n this.afterTestRunHookDefinitionConfigs = []\n this.afterTestStepHookDefinitionConfigs = []\n this.beforeTestCaseHookDefinitionConfigs = []\n this.beforeTestRunHookDefinitionConfigs = []\n this.beforeTestStepHookDefinitionConfigs = []\n this.definitionFunctionWrapper = null\n this.defaultTimeout = 5000\n this.parameterTypeRegistry = new ParameterTypeRegistry()\n this.stepDefinitionConfigs = []\n this.World = World\n }\n}\n\nexport default new SupportCodeLibraryBuilder()\n"]}
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
2
2
|
import TestCaseHookDefinition from '../models/test_case_hook_definition';
|
|
3
3
|
import TestStepHookDefinition from '../models/test_step_hook_definition';
|
|
4
4
|
import TestRunHookDefinition from '../models/test_run_hook_definition';
|
|
5
5
|
import StepDefinition from '../models/step_definition';
|
|
6
6
|
import { ParameterTypeRegistry } from '@cucumber/cucumber-expressions';
|
|
7
|
+
import { IWorld } from './world';
|
|
7
8
|
export declare type DefineStepPattern = string | RegExp;
|
|
8
9
|
export interface ITestCaseHookParameter {
|
|
9
|
-
gherkinDocument: messages.
|
|
10
|
-
pickle: messages.
|
|
11
|
-
result?: messages.
|
|
10
|
+
gherkinDocument: messages.GherkinDocument;
|
|
11
|
+
pickle: messages.Pickle;
|
|
12
|
+
result?: messages.TestStepResult;
|
|
12
13
|
testCaseStartedId: string;
|
|
13
14
|
}
|
|
14
15
|
export interface ITestStepHookParameter {
|
|
15
|
-
gherkinDocument: messages.
|
|
16
|
-
pickle: messages.
|
|
17
|
-
|
|
16
|
+
gherkinDocument: messages.GherkinDocument;
|
|
17
|
+
pickle: messages.Pickle;
|
|
18
|
+
pickleStep: messages.PickleStep;
|
|
19
|
+
result: messages.TestStepResult;
|
|
18
20
|
testCaseStartedId: string;
|
|
19
21
|
testStepId: string;
|
|
20
22
|
}
|
|
21
|
-
export declare type
|
|
22
|
-
export declare type
|
|
23
|
-
export declare type
|
|
24
|
-
export declare type TestStepHookFunctionWithoutParameter = () => void;
|
|
25
|
-
export declare type TestStepHookFunctionWithParameter = (arg: ITestStepHookParameter) => void;
|
|
26
|
-
export declare type TestStepHookFunction = TestStepHookFunctionWithoutParameter | TestStepHookFunctionWithParameter;
|
|
23
|
+
export declare type TestCaseHookFunction<WorldType> = (this: WorldType, arg: ITestCaseHookParameter) => any | Promise<any>;
|
|
24
|
+
export declare type TestStepHookFunction<WorldType> = (this: WorldType, arg: ITestStepHookParameter) => void;
|
|
25
|
+
export declare type TestStepFunction<WorldType> = (this: WorldType, ...args: any[]) => any | Promise<any>;
|
|
27
26
|
export interface IDefineStepOptions {
|
|
28
27
|
timeout?: number;
|
|
29
28
|
wrapperOptions?: any;
|
|
@@ -41,26 +40,26 @@ export interface IDefineTestRunHookOptions {
|
|
|
41
40
|
}
|
|
42
41
|
export interface IParameterTypeDefinition<T> {
|
|
43
42
|
name: string;
|
|
44
|
-
regexp: RegExp;
|
|
43
|
+
regexp: readonly RegExp[] | readonly string[] | RegExp | string;
|
|
45
44
|
transformer: (...match: string[]) => T;
|
|
46
45
|
useForSnippets?: boolean;
|
|
47
46
|
preferForRegexpMatch?: boolean;
|
|
48
47
|
}
|
|
49
48
|
export interface IDefineSupportCodeMethods {
|
|
50
49
|
defineParameterType: (options: IParameterTypeDefinition<any>) => void;
|
|
51
|
-
defineStep: ((pattern: DefineStepPattern, code:
|
|
50
|
+
defineStep: (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
|
|
52
51
|
setDefaultTimeout: (milliseconds: number) => void;
|
|
53
52
|
setDefinitionFunctionWrapper: (fn: Function) => void;
|
|
54
53
|
setWorldConstructor: (fn: any) => void;
|
|
55
|
-
After: ((code: TestCaseHookFunction) => void) & ((tags: string, code: TestCaseHookFunction) => void) & ((options: IDefineTestCaseHookOptions, code: TestCaseHookFunction) => void);
|
|
56
|
-
AfterStep: ((code: TestStepHookFunction) => void) & ((tags: string, code: TestStepHookFunction) => void) & ((options: IDefineTestStepHookOptions, code: TestStepHookFunction) => void);
|
|
54
|
+
After: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestCaseHookOptions, code: TestCaseHookFunction<WorldType>) => void);
|
|
55
|
+
AfterStep: (<WorldType = IWorld>(code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestStepHookOptions, code: TestStepHookFunction<WorldType>) => void);
|
|
57
56
|
AfterAll: ((code: Function) => void) & ((options: IDefineTestRunHookOptions, code: Function) => void);
|
|
58
|
-
Before: ((code: TestCaseHookFunction) => void) & ((tags: string, code: TestCaseHookFunction) => void) & ((options: IDefineTestCaseHookOptions, code: TestCaseHookFunction) => void);
|
|
59
|
-
BeforeStep: ((code: TestStepHookFunction) => void) & ((tags: string, code: TestStepHookFunction) => void) & ((options: IDefineTestStepHookOptions, code: TestStepHookFunction) => void);
|
|
57
|
+
Before: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestCaseHookOptions, code: TestCaseHookFunction<WorldType>) => void);
|
|
58
|
+
BeforeStep: (<WorldType = IWorld>(code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestStepHookOptions, code: TestStepHookFunction<WorldType>) => void);
|
|
60
59
|
BeforeAll: ((code: Function) => void) & ((options: IDefineTestRunHookOptions, code: Function) => void);
|
|
61
|
-
Given: ((pattern: DefineStepPattern, code:
|
|
62
|
-
Then: ((pattern: DefineStepPattern, code:
|
|
63
|
-
When: ((pattern: DefineStepPattern, code:
|
|
60
|
+
Given: (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
|
|
61
|
+
Then: (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
|
|
62
|
+
When: (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
|
|
64
63
|
}
|
|
65
64
|
export interface ISupportCodeLibrary {
|
|
66
65
|
readonly afterTestCaseHookDefinitions: TestCaseHookDefinition[];
|
|
@@ -71,7 +70,7 @@ export interface ISupportCodeLibrary {
|
|
|
71
70
|
readonly beforeTestRunHookDefinitions: TestRunHookDefinition[];
|
|
72
71
|
readonly defaultTimeout: number;
|
|
73
72
|
readonly stepDefinitions: StepDefinition[];
|
|
74
|
-
readonly undefinedParameterTypes: messages.
|
|
73
|
+
readonly undefinedParameterTypes: messages.UndefinedParameterType[];
|
|
75
74
|
readonly parameterTypeRegistry: ParameterTypeRegistry;
|
|
76
75
|
readonly World: any;
|
|
77
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/support_code_library_builder/types.ts"],"names":[],"mappings":"","sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/support_code_library_builder/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as messages from '@cucumber/messages'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestStepHookDefinition from '../models/test_step_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport StepDefinition from '../models/step_definition'\nimport { ParameterTypeRegistry } from '@cucumber/cucumber-expressions'\nimport { IWorld } from './world'\n\nexport type DefineStepPattern = string | RegExp\n\nexport interface ITestCaseHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n result?: messages.TestStepResult\n testCaseStartedId: string\n}\n\nexport interface ITestStepHookParameter {\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n pickleStep: messages.PickleStep\n result: messages.TestStepResult\n testCaseStartedId: string\n testStepId: string\n}\n\nexport type TestCaseHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestCaseHookParameter\n) => any | Promise<any>\n\nexport type TestStepHookFunction<WorldType> = (\n this: WorldType,\n arg: ITestStepHookParameter\n) => void\n\nexport type TestStepFunction<WorldType> = (\n this: WorldType,\n ...args: any[]\n) => any | Promise<any>\n\nexport interface IDefineStepOptions {\n timeout?: number\n wrapperOptions?: any\n}\n\nexport interface IDefineTestCaseHookOptions {\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestStepHookOptions {\n tags?: string\n timeout?: number\n}\n\nexport interface IDefineTestRunHookOptions {\n timeout?: number\n}\n\nexport interface IParameterTypeDefinition<T> {\n name: string\n regexp: readonly RegExp[] | readonly string[] | RegExp | string\n transformer: (...match: string[]) => T\n useForSnippets?: boolean\n preferForRegexpMatch?: boolean\n}\n\nexport interface IDefineSupportCodeMethods {\n defineParameterType: (options: IParameterTypeDefinition<any>) => void\n defineStep: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n setDefaultTimeout: (milliseconds: number) => void\n setDefinitionFunctionWrapper: (fn: Function) => void\n setWorldConstructor: (fn: any) => void\n After: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n AfterStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n AfterAll: ((code: Function) => void) &\n ((options: IDefineTestRunHookOptions, code: Function) => void)\n Before: (<WorldType = IWorld>(\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestCaseHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestCaseHookOptions,\n code: TestCaseHookFunction<WorldType>\n ) => void)\n BeforeStep: (<WorldType = IWorld>(\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n tags: string,\n code: TestStepHookFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n options: IDefineTestStepHookOptions,\n code: TestStepHookFunction<WorldType>\n ) => void)\n BeforeAll: ((code: Function) => void) &\n ((options: IDefineTestRunHookOptions, code: Function) => void)\n Given: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n Then: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n When: (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n code: TestStepFunction<WorldType>\n ) => void) &\n (<WorldType = IWorld>(\n pattern: DefineStepPattern,\n options: IDefineStepOptions,\n code: TestStepFunction<WorldType>\n ) => void)\n}\n\nexport interface ISupportCodeLibrary {\n readonly afterTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly afterTestStepHookDefinitions: TestStepHookDefinition[]\n readonly afterTestRunHookDefinitions: TestRunHookDefinition[]\n readonly beforeTestCaseHookDefinitions: TestCaseHookDefinition[]\n readonly beforeTestStepHookDefinitions: TestStepHookDefinition[]\n readonly beforeTestRunHookDefinitions: TestRunHookDefinition[]\n readonly defaultTimeout: number\n readonly stepDefinitions: StepDefinition[]\n readonly undefinedParameterTypes: messages.UndefinedParameterType[]\n readonly parameterTypeRegistry: ParameterTypeRegistry\n readonly World: any\n}\n"]}
|
|
@@ -1,70 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
7
|
-
const value_checker_1 = require("../value_checker");
|
|
8
3
|
const optionsValidation = {
|
|
9
4
|
expectedType: 'object or function',
|
|
10
5
|
predicate({ options }) {
|
|
11
|
-
return
|
|
6
|
+
return typeof options === 'object';
|
|
12
7
|
},
|
|
13
8
|
};
|
|
14
9
|
const optionsTimeoutValidation = {
|
|
15
10
|
identifier: '"options.timeout"',
|
|
16
11
|
expectedType: 'integer',
|
|
17
12
|
predicate({ options }) {
|
|
18
|
-
return
|
|
13
|
+
return options.timeout == null || typeof options.timeout === 'number';
|
|
19
14
|
},
|
|
20
15
|
};
|
|
21
16
|
const fnValidation = {
|
|
22
17
|
expectedType: 'function',
|
|
23
18
|
predicate({ code }) {
|
|
24
|
-
return
|
|
19
|
+
return typeof code === 'function';
|
|
25
20
|
},
|
|
26
21
|
};
|
|
27
22
|
const validations = {
|
|
28
23
|
defineTestRunHook: [
|
|
29
|
-
|
|
24
|
+
{ identifier: 'first argument', ...optionsValidation },
|
|
30
25
|
optionsTimeoutValidation,
|
|
31
|
-
|
|
26
|
+
{ identifier: 'second argument', ...fnValidation },
|
|
32
27
|
],
|
|
33
28
|
defineTestCaseHook: [
|
|
34
|
-
|
|
29
|
+
{ identifier: 'first argument', ...optionsValidation },
|
|
35
30
|
{
|
|
36
31
|
identifier: '"options.tags"',
|
|
37
32
|
expectedType: 'string',
|
|
38
33
|
predicate({ options }) {
|
|
39
|
-
return
|
|
34
|
+
return options.tags == null || typeof options.tags === 'string';
|
|
40
35
|
},
|
|
41
36
|
},
|
|
42
37
|
optionsTimeoutValidation,
|
|
43
|
-
|
|
38
|
+
{ identifier: 'second argument', ...fnValidation },
|
|
44
39
|
],
|
|
45
40
|
defineTestStepHook: [
|
|
46
|
-
|
|
41
|
+
{ identifier: 'first argument', ...optionsValidation },
|
|
47
42
|
{
|
|
48
43
|
identifier: '"options.tags"',
|
|
49
44
|
expectedType: 'string',
|
|
50
45
|
predicate({ options }) {
|
|
51
|
-
return
|
|
46
|
+
return options.tags == null || typeof options.tags === 'string';
|
|
52
47
|
},
|
|
53
48
|
},
|
|
54
49
|
optionsTimeoutValidation,
|
|
55
|
-
|
|
50
|
+
{ identifier: 'second argument', ...fnValidation },
|
|
56
51
|
],
|
|
57
52
|
defineStep: [
|
|
58
53
|
{
|
|
59
54
|
identifier: 'first argument',
|
|
60
55
|
expectedType: 'string or regular expression',
|
|
61
56
|
predicate({ pattern }) {
|
|
62
|
-
return
|
|
57
|
+
return pattern instanceof RegExp || typeof pattern === 'string';
|
|
63
58
|
},
|
|
64
59
|
},
|
|
65
|
-
|
|
60
|
+
{ identifier: 'second argument', ...optionsValidation },
|
|
66
61
|
optionsTimeoutValidation,
|
|
67
|
-
|
|
62
|
+
{ identifier: 'third argument', ...fnValidation },
|
|
68
63
|
],
|
|
69
64
|
};
|
|
70
65
|
function validateArguments({ args, fnName, location, }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate_arguments.js","sourceRoot":"","sources":["../../src/support_code_library_builder/validate_arguments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate_arguments.js","sourceRoot":"","sources":["../../src/support_code_library_builder/validate_arguments.ts"],"names":[],"mappings":";;AAcA,MAAM,iBAAiB,GAAG;IACxB,YAAY,EAAE,oBAAoB;IAClC,SAAS,CAAC,EAAE,OAAO,EAAwB;QACzC,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAA;IACpC,CAAC;CACF,CAAA;AAED,MAAM,wBAAwB,GAAG;IAC/B,UAAU,EAAE,mBAAmB;IAC/B,YAAY,EAAE,SAAS;IACvB,SAAS,CAAC,EAAE,OAAO,EAAwB;QACzC,OAAO,OAAO,CAAC,OAAO,IAAI,IAAI,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAA;IACvE,CAAC;CACF,CAAA;AAED,MAAM,YAAY,GAAG;IACnB,YAAY,EAAE,UAAU;IACxB,SAAS,CAAC,EAAE,IAAI,EAAwB;QACtC,OAAO,OAAO,IAAI,KAAK,UAAU,CAAA;IACnC,CAAC;CACF,CAAA;AAED,MAAM,WAA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wB,iBAAiB,CAAC,EACxC,IAAI,EACJ,MAAM,EACN,QAAQ,GAKT;IACC,WAAW,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE;QACtE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;YACpB,MAAM,IAAI,KAAK,CACb,GAAG,QAAQ,aAAa,UAAU,iBAAiB,YAAY,EAAE,CAClE,CAAA;SACF;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAhBD,oCAgBC","sourcesContent":["import { DefineStepPattern, IDefineStepOptions } from './types'\n\ninterface IValidation {\n identifier: string\n expectedType: string\n predicate: (args: any) => boolean\n}\n\ninterface IDefineStepArguments {\n pattern?: DefineStepPattern\n options?: IDefineStepOptions\n code?: Function\n}\n\nconst optionsValidation = {\n expectedType: 'object or function',\n predicate({ options }: IDefineStepArguments) {\n return typeof options === 'object'\n },\n}\n\nconst optionsTimeoutValidation = {\n identifier: '\"options.timeout\"',\n expectedType: 'integer',\n predicate({ options }: IDefineStepArguments) {\n return options.timeout == null || typeof options.timeout === 'number'\n },\n}\n\nconst fnValidation = {\n expectedType: 'function',\n predicate({ code }: IDefineStepArguments) {\n return typeof code === 'function'\n },\n}\n\nconst validations: Record<string, IValidation[]> = {\n defineTestRunHook: [\n { identifier: 'first argument', ...optionsValidation },\n optionsTimeoutValidation,\n { identifier: 'second argument', ...fnValidation },\n ],\n defineTestCaseHook: [\n { identifier: 'first argument', ...optionsValidation },\n {\n identifier: '\"options.tags\"',\n expectedType: 'string',\n predicate({ options }) {\n return options.tags == null || typeof options.tags === 'string'\n },\n },\n optionsTimeoutValidation,\n { identifier: 'second argument', ...fnValidation },\n ],\n defineTestStepHook: [\n { identifier: 'first argument', ...optionsValidation },\n {\n identifier: '\"options.tags\"',\n expectedType: 'string',\n predicate({ options }) {\n return options.tags == null || typeof options.tags === 'string'\n },\n },\n optionsTimeoutValidation,\n { identifier: 'second argument', ...fnValidation },\n ],\n defineStep: [\n {\n identifier: 'first argument',\n expectedType: 'string or regular expression',\n predicate({ pattern }) {\n return pattern instanceof RegExp || typeof pattern === 'string'\n },\n },\n { identifier: 'second argument', ...optionsValidation },\n optionsTimeoutValidation,\n { identifier: 'third argument', ...fnValidation },\n ],\n}\n\nexport default function validateArguments({\n args,\n fnName,\n location,\n}: {\n args?: IDefineStepArguments\n fnName: string\n location: string\n}): void {\n validations[fnName].forEach(({ identifier, expectedType, predicate }) => {\n if (!predicate(args)) {\n throw new Error(\n `${location}: Invalid ${identifier}: should be a ${expectedType}`\n )\n }\n })\n}\n"]}
|
|
@@ -4,7 +4,13 @@ export interface IWorldOptions {
|
|
|
4
4
|
log: ICreateLog;
|
|
5
5
|
parameters: any;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export interface IWorld {
|
|
8
|
+
readonly attach: ICreateAttachment;
|
|
9
|
+
readonly log: ICreateLog;
|
|
10
|
+
readonly parameters: any;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export default class World implements IWorld {
|
|
8
14
|
readonly attach: ICreateAttachment;
|
|
9
15
|
readonly log: ICreateLog;
|
|
10
16
|
readonly parameters: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../src/support_code_library_builder/world.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../src/support_code_library_builder/world.ts"],"names":[],"mappings":";;AAeA,MAAqB,KAAK;IAKxB,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAiB;QACpD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAVD,wBAUC","sourcesContent":["import { ICreateAttachment, ICreateLog } from '../runtime/attachment_manager'\n\nexport interface IWorldOptions {\n attach: ICreateAttachment\n log: ICreateLog\n parameters: any\n}\n\nexport interface IWorld {\n readonly attach: ICreateAttachment\n readonly log: ICreateLog\n readonly parameters: any\n [key: string]: any\n}\n\nexport default class World implements IWorld {\n public readonly attach: ICreateAttachment\n public readonly log: ICreateLog\n public readonly parameters: any\n\n constructor({ attach, log, parameters }: IWorldOptions) {\n this.attach = attach\n this.log = log\n this.parameters = parameters\n }\n}\n"]}
|
package/lib/time.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const NANOSECONDS_IN_MILLISECOND = 1000000;
|
|
3
|
-
export declare const MILLISECONDS_IN_SECOND = 1000;
|
|
4
|
-
export declare const NANOSECONDS_IN_SECOND = 1000000000;
|
|
1
|
+
import * as messages from '@cucumber/messages';
|
|
5
2
|
declare const methods: any;
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function durationToMilliseconds(duration: messages.IDuration): number;
|
|
9
|
-
export declare function durationToNanoseconds(duration: messages.IDuration): number;
|
|
10
|
-
export declare function durationBetweenTimestamps(startedTimestamp: messages.ITimestamp, finishedTimestamp: messages.ITimestamp): messages.IDuration;
|
|
11
|
-
export declare function getZeroDuration(): messages.IDuration;
|
|
3
|
+
export declare function durationBetweenTimestamps(startedTimestamp: messages.Timestamp, finishedTimestamp: messages.Timestamp): messages.Duration;
|
|
4
|
+
export declare function wrapPromiseWithTimeout<T>(promise: Promise<T>, timeoutInMilliseconds: number, timeoutMessage?: string): Promise<T>;
|
|
12
5
|
export default methods;
|
package/lib/time.js
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
exports.NANOSECONDS_IN_MILLISECOND = 1e6;
|
|
7
|
-
exports.MILLISECONDS_IN_SECOND = 1e3;
|
|
8
|
-
exports.NANOSECONDS_IN_SECOND = 1e9;
|
|
22
|
+
exports.wrapPromiseWithTimeout = exports.durationBetweenTimestamps = void 0;
|
|
23
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
24
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
9
25
|
let previousTimestamp;
|
|
10
26
|
const methods = {
|
|
11
27
|
beginTiming() {
|
|
@@ -19,58 +35,33 @@ const methods = {
|
|
|
19
35
|
},
|
|
20
36
|
setInterval: setInterval.bind(global),
|
|
21
37
|
setTimeout: setTimeout.bind(global),
|
|
38
|
+
performance: perf_hooks_1.performance,
|
|
22
39
|
};
|
|
23
40
|
if (typeof setImmediate !== 'undefined') {
|
|
24
41
|
methods.setImmediate = setImmediate.bind(global);
|
|
25
42
|
methods.clearImmediate = clearImmediate.bind(global);
|
|
26
43
|
}
|
|
27
44
|
function getTimestamp() {
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
function toNumber(x) {
|
|
31
|
-
return typeof x === 'number' ? x : x.toNumber();
|
|
32
|
-
}
|
|
33
|
-
function addDurations(a, b) {
|
|
34
|
-
if (value_checker_1.doesNotHaveValue(b)) {
|
|
35
|
-
return a;
|
|
36
|
-
}
|
|
37
|
-
let seconds = toNumber(a.seconds) + toNumber(b.seconds);
|
|
38
|
-
let nanos = a.nanos + b.nanos;
|
|
39
|
-
if (nanos > exports.NANOSECONDS_IN_SECOND) {
|
|
40
|
-
seconds += 1;
|
|
41
|
-
nanos -= exports.NANOSECONDS_IN_SECOND;
|
|
42
|
-
}
|
|
43
|
-
return new messages_1.messages.Duration({ seconds, nanos });
|
|
45
|
+
return methods.performance.now();
|
|
44
46
|
}
|
|
45
|
-
exports.addDurations = addDurations;
|
|
46
|
-
// TODO use TimeConversion methods in cucumber-messages
|
|
47
|
-
// dependent on https://github.com/cucumber/cucumber/pull/832
|
|
48
|
-
function millisecondsToDuration(milliseconds) {
|
|
49
|
-
const seconds = Math.floor(milliseconds / exports.MILLISECONDS_IN_SECOND);
|
|
50
|
-
const nanos = (milliseconds - seconds * exports.MILLISECONDS_IN_SECOND) *
|
|
51
|
-
exports.NANOSECONDS_IN_MILLISECOND;
|
|
52
|
-
return new messages_1.messages.Duration({ seconds, nanos });
|
|
53
|
-
}
|
|
54
|
-
exports.millisecondsToDuration = millisecondsToDuration;
|
|
55
|
-
function durationToMilliseconds(duration) {
|
|
56
|
-
const secondMillis = toNumber(duration.seconds) * exports.MILLISECONDS_IN_SECOND;
|
|
57
|
-
const nanoMillis = duration.nanos / exports.NANOSECONDS_IN_MILLISECOND;
|
|
58
|
-
return secondMillis + nanoMillis;
|
|
59
|
-
}
|
|
60
|
-
exports.durationToMilliseconds = durationToMilliseconds;
|
|
61
|
-
function durationToNanoseconds(duration) {
|
|
62
|
-
return toNumber(duration.seconds) * exports.NANOSECONDS_IN_SECOND + duration.nanos;
|
|
63
|
-
}
|
|
64
|
-
exports.durationToNanoseconds = durationToNanoseconds;
|
|
65
47
|
function durationBetweenTimestamps(startedTimestamp, finishedTimestamp) {
|
|
66
|
-
const durationMillis =
|
|
67
|
-
|
|
68
|
-
return
|
|
48
|
+
const durationMillis = messages.TimeConversion.timestampToMillisecondsSinceEpoch(finishedTimestamp) -
|
|
49
|
+
messages.TimeConversion.timestampToMillisecondsSinceEpoch(startedTimestamp);
|
|
50
|
+
return messages.TimeConversion.millisecondsToDuration(durationMillis);
|
|
69
51
|
}
|
|
70
52
|
exports.durationBetweenTimestamps = durationBetweenTimestamps;
|
|
71
|
-
function
|
|
72
|
-
|
|
53
|
+
async function wrapPromiseWithTimeout(promise, timeoutInMilliseconds, timeoutMessage = '') {
|
|
54
|
+
let timeoutId;
|
|
55
|
+
if (timeoutMessage === '') {
|
|
56
|
+
timeoutMessage = `Action did not complete within ${timeoutInMilliseconds} milliseconds`;
|
|
57
|
+
}
|
|
58
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
|
59
|
+
timeoutId = methods.setTimeout(() => {
|
|
60
|
+
reject(new Error(timeoutMessage));
|
|
61
|
+
}, timeoutInMilliseconds);
|
|
62
|
+
});
|
|
63
|
+
return await Promise.race([promise, timeoutPromise]).finally(() => methods.clearTimeout(timeoutId));
|
|
73
64
|
}
|
|
74
|
-
exports.
|
|
65
|
+
exports.wrapPromiseWithTimeout = wrapPromiseWithTimeout;
|
|
75
66
|
exports.default = methods;
|
|
76
67
|
//# sourceMappingURL=time.js.map
|