@cucumber/cucumber 7.2.0 → 7.3.2
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/lib/cli/argv_parser.d.ts +0 -1
- package/lib/cli/argv_parser.js +0 -1
- package/lib/cli/argv_parser.js.map +1 -1
- package/lib/cli/configuration_builder.d.ts +0 -1
- package/lib/cli/configuration_builder.js +5 -5
- package/lib/cli/configuration_builder.js.map +1 -1
- package/lib/cli/helpers.js +41 -22
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/index.d.ts +1 -3
- package/lib/cli/index.js +27 -30
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/profile_loader.d.ts +2 -5
- package/lib/cli/profile_loader.js +2 -3
- 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 +4 -8
- package/lib/formatter/builder.js +17 -32
- 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 +14 -17
- package/lib/formatter/helpers/event_data_collector.js +14 -8
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -6
- package/lib/formatter/helpers/gherkin_document_parser.js +1 -4
- 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 +5 -6
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.d.ts +9 -10
- 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 +32 -14
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +33 -14
- 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 +27 -9
- 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 +44 -15
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
- package/lib/formatter/html_formatter.js +1 -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/json_formatter.d.ts +21 -27
- package/lib/formatter/json_formatter.js +50 -23
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.js +1 -1
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +6 -6
- package/lib/formatter/progress_bar_formatter.js +3 -3
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +2 -2
- package/lib/formatter/progress_formatter.js +29 -10
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/rerun_formatter.js +22 -4
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.js +21 -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.map +1 -1
- package/lib/formatter/summary_formatter.d.ts +2 -2
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.js +22 -3
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/index.d.ts +14 -12
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.d.ts +3 -4
- 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/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 +4 -4
- 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 +2 -2
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +4 -3
- package/lib/runtime/index.js +31 -13
- 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 +10 -9
- package/lib/runtime/parallel/coordinator.js +54 -43
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -2
- package/lib/runtime/parallel/worker.js +8 -14
- 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 -12
- 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/{pickle_runner.d.ts → test_case_runner.d.ts} +16 -32
- package/lib/runtime/{pickle_runner.js → test_case_runner.js} +104 -147
- package/lib/runtime/test_case_runner.js.map +1 -0
- package/lib/step_arguments.d.ts +4 -4
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/index.d.ts +9 -7
- package/lib/support_code_library_builder/index.js +11 -10
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +21 -23
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/support_code_library_builder/validate_arguments.js +8 -8
- 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 +2 -10
- package/lib/time.js +24 -48
- package/lib/time.js.map +1 -1
- package/package.json +38 -40
- package/CHANGELOG.md +0 -1874
- package/lib/importers.js +0 -17
- 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/wrapper.mjs +0 -38
|
@@ -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;
|
|
@@ -35,6 +35,7 @@ class SupportCodeLibraryBuilder {
|
|
|
35
35
|
this.defaultTimeout = milliseconds;
|
|
36
36
|
},
|
|
37
37
|
setDefinitionFunctionWrapper: (fn) => {
|
|
38
|
+
console.log(`setDefinitionFunctionWrapper is deprecated and will be removed in version 8.0.0 of cucumber-js. If this was used to wrap generator functions, please transition to using async / await. If this was used to wrap step definitions, please use BeforeStep / AfterStep hooks instead. If you had other use cases, please create an issue.`);
|
|
38
39
|
this.definitionFunctionWrapper = fn;
|
|
39
40
|
},
|
|
40
41
|
setWorldConstructor: (fn) => {
|
|
@@ -144,15 +145,15 @@ class SupportCodeLibraryBuilder {
|
|
|
144
145
|
}
|
|
145
146
|
return code;
|
|
146
147
|
}
|
|
147
|
-
buildTestCaseHookDefinitions(configs) {
|
|
148
|
-
return configs.map(({ code, line, options, uri }) => {
|
|
148
|
+
buildTestCaseHookDefinitions(configs, canonicalIds) {
|
|
149
|
+
return configs.map(({ code, line, options, uri }, index) => {
|
|
149
150
|
const wrappedCode = this.wrapCode({
|
|
150
151
|
code,
|
|
151
152
|
wrapperOptions: options.wrapperOptions,
|
|
152
153
|
});
|
|
153
154
|
return new test_case_hook_definition_1.default({
|
|
154
155
|
code: wrappedCode,
|
|
155
|
-
id: this.newId(),
|
|
156
|
+
id: canonicalIds ? canonicalIds[index] : this.newId(),
|
|
156
157
|
line,
|
|
157
158
|
options,
|
|
158
159
|
unwrappedCode: code,
|
|
@@ -192,10 +193,10 @@ class SupportCodeLibraryBuilder {
|
|
|
192
193
|
});
|
|
193
194
|
});
|
|
194
195
|
}
|
|
195
|
-
buildStepDefinitions() {
|
|
196
|
+
buildStepDefinitions(canonicalIds) {
|
|
196
197
|
const stepDefinitions = [];
|
|
197
198
|
const undefinedParameterTypes = [];
|
|
198
|
-
this.stepDefinitionConfigs.forEach(({ code, line, options, pattern, uri }) => {
|
|
199
|
+
this.stepDefinitionConfigs.forEach(({ code, line, options, pattern, uri }, index) => {
|
|
199
200
|
let expression;
|
|
200
201
|
if (typeof pattern === 'string') {
|
|
201
202
|
try {
|
|
@@ -222,7 +223,7 @@ class SupportCodeLibraryBuilder {
|
|
|
222
223
|
stepDefinitions.push(new step_definition_1.default({
|
|
223
224
|
code: wrappedCode,
|
|
224
225
|
expression,
|
|
225
|
-
id: this.newId(),
|
|
226
|
+
id: canonicalIds ? canonicalIds[index] : this.newId(),
|
|
226
227
|
line,
|
|
227
228
|
options,
|
|
228
229
|
pattern,
|
|
@@ -232,7 +233,7 @@ class SupportCodeLibraryBuilder {
|
|
|
232
233
|
});
|
|
233
234
|
return { stepDefinitions, undefinedParameterTypes };
|
|
234
235
|
}
|
|
235
|
-
finalize() {
|
|
236
|
+
finalize(canonicalIds) {
|
|
236
237
|
if (value_checker_1.doesNotHaveValue(this.definitionFunctionWrapper)) {
|
|
237
238
|
const definitionConfigs = lodash_1.default.chain([
|
|
238
239
|
this.afterTestCaseHookDefinitionConfigs,
|
|
@@ -245,12 +246,12 @@ class SupportCodeLibraryBuilder {
|
|
|
245
246
|
.value();
|
|
246
247
|
finalize_helpers_1.validateNoGeneratorFunctions({ cwd: this.cwd, definitionConfigs });
|
|
247
248
|
}
|
|
248
|
-
const stepDefinitionsResult = this.buildStepDefinitions();
|
|
249
|
+
const stepDefinitionsResult = this.buildStepDefinitions(canonicalIds === null || canonicalIds === void 0 ? void 0 : canonicalIds.stepDefinitionIds);
|
|
249
250
|
return {
|
|
250
|
-
afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.afterTestCaseHookDefinitionConfigs),
|
|
251
|
+
afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.afterTestCaseHookDefinitionConfigs, canonicalIds === null || canonicalIds === void 0 ? void 0 : canonicalIds.afterTestCaseHookDefinitionIds),
|
|
251
252
|
afterTestRunHookDefinitions: this.buildTestRunHookDefinitions(this.afterTestRunHookDefinitionConfigs),
|
|
252
253
|
afterTestStepHookDefinitions: this.buildTestStepHookDefinitions(this.afterTestStepHookDefinitionConfigs),
|
|
253
|
-
beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.beforeTestCaseHookDefinitionConfigs),
|
|
254
|
+
beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.beforeTestCaseHookDefinitionConfigs, canonicalIds === null || canonicalIds === void 0 ? void 0 : canonicalIds.beforeTestCaseHookDefinitionIds),
|
|
254
255
|
beforeTestRunHookDefinitions: this.buildTestRunHookDefinitions(this.beforeTestRunHookDefinitionConfigs),
|
|
255
256
|
beforeTestStepHookDefinitions: this.buildTestStepHookDefinitions(this.beforeTestStepHookDefinitionConfigs),
|
|
256
257
|
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,oGAAwE;AACxE,kGAAsE;AACtE,gFAAsD;AACtD,kDAAqD;AACrD,8EAAoD;AACpD,4DAA8B;AAE9B,yEAIuC;AACvC,oDAAkE;AAClE,yDAAiE;AAajE,oDAA2B;AA+Bd,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,kBAAk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ACxC;YACD,6BAA6B,EAAE,IAAI,CAAC,4BAA4B,CAC9D,IAAI,CAAC,mCAAmC,CACzC;YACD,4BAA4B,EAAE,IAAI,CAAC,2BAA2B,CAC5D,IAAI,CAAC,kCAAkC,CACxC;YACD,6BAA6B,EAAE,IAAI,CAAC,4BAA4B,CAC9D,IAAI,CAAC,mCAAmC,CACzC;YACD,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;YACjD,uBAAuB,EAAE,qBAAqB,CAAC,uBAAuB;YACtE,eAAe,EAAE,qBAAqB,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;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","sourceRo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jD,uBAAuB,EAAE,qBAAqB,CAAC,uBAAuB;YACtE,eAAe,EAAE,qBAAqB,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;AArXD,8DAqXC;AAED,kBAAe,IAAI,yBAAyB,EAAE,CAAA","sourcesContent":["import _ from 'lodash'\nimport { 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, 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'\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 console.log(\n `setDefinitionFunctionWrapper is deprecated and will be removed in version 8.0.0 of cucumber-js. If this was used to wrap generator functions, please transition to using async / await. If this was used to wrap step definitions, please use BeforeStep / AfterStep hooks instead. If you had other use cases, please create an issue.`\n )\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 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 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,27 @@
|
|
|
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
|
-
result: messages.
|
|
16
|
+
gherkinDocument: messages.GherkinDocument;
|
|
17
|
+
pickle: messages.Pickle;
|
|
18
|
+
result: messages.TestStepResult;
|
|
18
19
|
testCaseStartedId: string;
|
|
19
20
|
testStepId: string;
|
|
20
21
|
}
|
|
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;
|
|
22
|
+
export declare type TestCaseHookFunction<WorldType> = (this: WorldType, arg: ITestCaseHookParameter) => any | Promise<any>;
|
|
23
|
+
export declare type TestStepHookFunction<WorldType> = (this: WorldType, arg: ITestStepHookParameter) => void;
|
|
24
|
+
export declare type TestStepFunction<WorldType> = (this: WorldType, ...args: any[]) => any | Promise<any>;
|
|
27
25
|
export interface IDefineStepOptions {
|
|
28
26
|
timeout?: number;
|
|
29
27
|
wrapperOptions?: any;
|
|
@@ -41,26 +39,26 @@ export interface IDefineTestRunHookOptions {
|
|
|
41
39
|
}
|
|
42
40
|
export interface IParameterTypeDefinition<T> {
|
|
43
41
|
name: string;
|
|
44
|
-
regexp: RegExp;
|
|
42
|
+
regexp: readonly RegExp[] | readonly string[] | RegExp | string;
|
|
45
43
|
transformer: (...match: string[]) => T;
|
|
46
44
|
useForSnippets?: boolean;
|
|
47
45
|
preferForRegexpMatch?: boolean;
|
|
48
46
|
}
|
|
49
47
|
export interface IDefineSupportCodeMethods {
|
|
50
48
|
defineParameterType: (options: IParameterTypeDefinition<any>) => void;
|
|
51
|
-
defineStep: ((pattern: DefineStepPattern, code:
|
|
49
|
+
defineStep: (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
|
|
52
50
|
setDefaultTimeout: (milliseconds: number) => void;
|
|
53
51
|
setDefinitionFunctionWrapper: (fn: Function) => void;
|
|
54
52
|
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);
|
|
53
|
+
After: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestCaseHookOptions, code: TestCaseHookFunction<WorldType>) => void);
|
|
54
|
+
AfterStep: (<WorldType = IWorld>(code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestStepHookOptions, code: TestStepHookFunction<WorldType>) => void);
|
|
57
55
|
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);
|
|
56
|
+
Before: (<WorldType = IWorld>(code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestCaseHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestCaseHookOptions, code: TestCaseHookFunction<WorldType>) => void);
|
|
57
|
+
BeforeStep: (<WorldType = IWorld>(code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(tags: string, code: TestStepHookFunction<WorldType>) => void) & (<WorldType = IWorld>(options: IDefineTestStepHookOptions, code: TestStepHookFunction<WorldType>) => void);
|
|
60
58
|
BeforeAll: ((code: Function) => void) & ((options: IDefineTestRunHookOptions, code: Function) => void);
|
|
61
|
-
Given: ((pattern: DefineStepPattern, code:
|
|
62
|
-
Then: ((pattern: DefineStepPattern, code:
|
|
63
|
-
When: ((pattern: DefineStepPattern, code:
|
|
59
|
+
Given: (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
|
|
60
|
+
Then: (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
|
|
61
|
+
When: (<WorldType = IWorld>(pattern: DefineStepPattern, code: TestStepFunction<WorldType>) => void) & (<WorldType = IWorld>(pattern: DefineStepPattern, options: IDefineStepOptions, code: TestStepFunction<WorldType>) => void);
|
|
64
62
|
}
|
|
65
63
|
export interface ISupportCodeLibrary {
|
|
66
64
|
readonly afterTestCaseHookDefinitions: TestCaseHookDefinition[];
|
|
@@ -71,7 +69,7 @@ export interface ISupportCodeLibrary {
|
|
|
71
69
|
readonly beforeTestRunHookDefinitions: TestRunHookDefinition[];
|
|
72
70
|
readonly defaultTimeout: number;
|
|
73
71
|
readonly stepDefinitions: StepDefinition[];
|
|
74
|
-
readonly undefinedParameterTypes: messages.
|
|
72
|
+
readonly undefinedParameterTypes: messages.UndefinedParameterType[];
|
|
75
73
|
readonly parameterTypeRegistry: ParameterTypeRegistry;
|
|
76
74
|
readonly World: any;
|
|
77
75
|
}
|
|
@@ -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 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"]}
|
|
@@ -26,12 +26,12 @@ const fnValidation = {
|
|
|
26
26
|
};
|
|
27
27
|
const validations = {
|
|
28
28
|
defineTestRunHook: [
|
|
29
|
-
{ identifier: 'first argument',
|
|
29
|
+
Object.assign({ identifier: 'first argument' }, optionsValidation),
|
|
30
30
|
optionsTimeoutValidation,
|
|
31
|
-
{ identifier: 'second argument',
|
|
31
|
+
Object.assign({ identifier: 'second argument' }, fnValidation),
|
|
32
32
|
],
|
|
33
33
|
defineTestCaseHook: [
|
|
34
|
-
{ identifier: 'first argument',
|
|
34
|
+
Object.assign({ identifier: 'first argument' }, optionsValidation),
|
|
35
35
|
{
|
|
36
36
|
identifier: '"options.tags"',
|
|
37
37
|
expectedType: 'string',
|
|
@@ -40,10 +40,10 @@ const validations = {
|
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
optionsTimeoutValidation,
|
|
43
|
-
{ identifier: 'second argument',
|
|
43
|
+
Object.assign({ identifier: 'second argument' }, fnValidation),
|
|
44
44
|
],
|
|
45
45
|
defineTestStepHook: [
|
|
46
|
-
{ identifier: 'first argument',
|
|
46
|
+
Object.assign({ identifier: 'first argument' }, optionsValidation),
|
|
47
47
|
{
|
|
48
48
|
identifier: '"options.tags"',
|
|
49
49
|
expectedType: 'string',
|
|
@@ -52,7 +52,7 @@ const validations = {
|
|
|
52
52
|
},
|
|
53
53
|
},
|
|
54
54
|
optionsTimeoutValidation,
|
|
55
|
-
{ identifier: 'second argument',
|
|
55
|
+
Object.assign({ identifier: 'second argument' }, fnValidation),
|
|
56
56
|
],
|
|
57
57
|
defineStep: [
|
|
58
58
|
{
|
|
@@ -62,9 +62,9 @@ const validations = {
|
|
|
62
62
|
return lodash_1.default.isRegExp(pattern) || lodash_1.default.isString(pattern);
|
|
63
63
|
},
|
|
64
64
|
},
|
|
65
|
-
{ identifier: 'second argument',
|
|
65
|
+
Object.assign({ identifier: 'second argument' }, optionsValidation),
|
|
66
66
|
optionsTimeoutValidation,
|
|
67
|
-
{ identifier: 'third argument',
|
|
67
|
+
Object.assign({ identifier: 'third argument' }, fnValidation),
|
|
68
68
|
],
|
|
69
69
|
};
|
|
70
70
|
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":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"validate_arguments.js","sourceRoot":"","sources":["../../src/support_code_library_builder/validate_arguments.ts"],"names":[],"mappings":";;;;;AAAA,oDAAsB;AACtB,oDAAmD;AAenD,MAAM,iBAAiB,GAAG;IACxB,YAAY,EAAE,oBAAoB;IAClC,SAAS,CAAC,EAAE,OAAO,EAAwB;QACzC,OAAO,gBAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IACjC,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,gCAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,gBAAC,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1E,CAAC;CACF,CAAA;AAED,MAAM,YAAY,GAAG;IACnB,YAAY,EAAE,UAAU;IACxB,SAAS,CAAC,EAAE,IAAI,EAAwB;QACtC,OAAO,gBAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;CACF,CAAA;AAED,MAAM,WAAW,GAAkC;IACjD,iBAAiB,EAAE;wBACf,UAAU,EAAE,gBAAgB,IAAK,iBAAiB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E,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 _ from 'lodash'\nimport { doesNotHaveValue } from '../value_checker'\nimport { 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 _.isPlainObject(options)\n },\n}\n\nconst optionsTimeoutValidation = {\n identifier: '\"options.timeout\"',\n expectedType: 'integer',\n predicate({ options }: IDefineStepArguments) {\n return doesNotHaveValue(options.timeout) || _.isInteger(options.timeout)\n },\n}\n\nconst fnValidation = {\n expectedType: 'function',\n predicate({ code }: IDefineStepArguments) {\n return _.isFunction(code)\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 doesNotHaveValue(options.tags) || _.isString(options.tags)\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 doesNotHaveValue(options.tags) || _.isString(options.tags)\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 _.isRegExp(pattern) || _.isString(pattern)\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,4 @@
|
|
|
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 millisecondsToDuration(milliseconds: number): messages.IDuration;
|
|
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;
|
|
12
4
|
export default methods;
|
package/lib/time.js
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const value_checker_1 = require("./value_checker");
|
|
6
|
-
exports.NANOSECONDS_IN_MILLISECOND = 1e6;
|
|
7
|
-
exports.MILLISECONDS_IN_SECOND = 1e3;
|
|
8
|
-
exports.NANOSECONDS_IN_SECOND = 1e9;
|
|
22
|
+
exports.durationBetweenTimestamps = void 0;
|
|
23
|
+
const messages = __importStar(require("@cucumber/messages"));
|
|
9
24
|
let previousTimestamp;
|
|
10
25
|
const methods = {
|
|
11
26
|
beginTiming() {
|
|
@@ -27,50 +42,11 @@ if (typeof setImmediate !== 'undefined') {
|
|
|
27
42
|
function getTimestamp() {
|
|
28
43
|
return new methods.Date().getTime();
|
|
29
44
|
}
|
|
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 });
|
|
44
|
-
}
|
|
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
45
|
function durationBetweenTimestamps(startedTimestamp, finishedTimestamp) {
|
|
66
|
-
const durationMillis =
|
|
67
|
-
|
|
68
|
-
return
|
|
46
|
+
const durationMillis = messages.TimeConversion.timestampToMillisecondsSinceEpoch(finishedTimestamp) -
|
|
47
|
+
messages.TimeConversion.timestampToMillisecondsSinceEpoch(startedTimestamp);
|
|
48
|
+
return messages.TimeConversion.millisecondsToDuration(durationMillis);
|
|
69
49
|
}
|
|
70
50
|
exports.durationBetweenTimestamps = durationBetweenTimestamps;
|
|
71
|
-
function getZeroDuration() {
|
|
72
|
-
return new messages_1.messages.Duration({ seconds: 0, nanos: 0 });
|
|
73
|
-
}
|
|
74
|
-
exports.getZeroDuration = getZeroDuration;
|
|
75
51
|
exports.default = methods;
|
|
76
52
|
//# sourceMappingURL=time.js.map
|
package/lib/time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAE9C,IAAI,iBAAyB,CAAA;AAE7B,MAAM,OAAO,GAAQ;IACnB,WAAW;QACT,iBAAiB,GAAG,YAAY,EAAE,CAAA;IACpC,CAAC;IACD,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;IACzC,YAAY,EAAE,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IACvC,IAAI;IACJ,SAAS;QACP,OAAO,YAAY,EAAE,GAAG,iBAAiB,CAAA;IAC3C,CAAC;IACD,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;IACrC,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;CACpC,CAAA;AAED,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;IACvC,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,OAAO,CAAC,cAAc,GAAG,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;CACrD;AAED,SAAS,YAAY;IACnB,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;AACrC,CAAC;AAED,SAAgB,yBAAyB,CACvC,gBAAoC,EACpC,iBAAqC;IAErC,MAAM,cAAc,GAClB,QAAQ,CAAC,cAAc,CAAC,iCAAiC,CACvD,iBAAiB,CAClB;QACD,QAAQ,CAAC,cAAc,CAAC,iCAAiC,CAAC,gBAAgB,CAAC,CAAA;IAC7E,OAAO,QAAQ,CAAC,cAAc,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAA;AACvE,CAAC;AAVD,8DAUC;AAED,kBAAe,OAAO,CAAA","sourcesContent":["import * as messages from '@cucumber/messages'\n\nlet previousTimestamp: number\n\nconst methods: any = {\n beginTiming() {\n previousTimestamp = getTimestamp()\n },\n clearInterval: clearInterval.bind(global),\n clearTimeout: clearTimeout.bind(global),\n Date,\n endTiming() {\n return getTimestamp() - previousTimestamp\n },\n setInterval: setInterval.bind(global),\n setTimeout: setTimeout.bind(global),\n}\n\nif (typeof setImmediate !== 'undefined') {\n methods.setImmediate = setImmediate.bind(global)\n methods.clearImmediate = clearImmediate.bind(global)\n}\n\nfunction getTimestamp(): number {\n return new methods.Date().getTime()\n}\n\nexport function durationBetweenTimestamps(\n startedTimestamp: messages.Timestamp,\n finishedTimestamp: messages.Timestamp\n): messages.Duration {\n const durationMillis =\n messages.TimeConversion.timestampToMillisecondsSinceEpoch(\n finishedTimestamp\n ) -\n messages.TimeConversion.timestampToMillisecondsSinceEpoch(startedTimestamp)\n return messages.TimeConversion.millisecondsToDuration(durationMillis)\n}\n\nexport default methods\n"]}
|