@cucumber/cucumber 7.2.1 → 7.3.0
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/CHANGELOG.md +28 -1
- package/lib/cli/configuration_builder.js +3 -3
- package/lib/cli/configuration_builder.js.map +1 -1
- package/lib/cli/helpers.js +40 -18
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/index.js +23 -15
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/profile_loader.d.ts +1 -2
- package/lib/cli/profile_loader.js.map +1 -1
- package/lib/formatter/get_color_fns.d.ts +2 -2
- package/lib/formatter/get_color_fns.js +7 -8
- 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 +30 -13
- 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/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 +10 -10
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +20 -22
- package/lib/support_code_library_builder/types.js.map +1 -1
- 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 +33 -33
- 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
|
@@ -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;
|
|
@@ -144,15 +144,15 @@ class SupportCodeLibraryBuilder {
|
|
|
144
144
|
}
|
|
145
145
|
return code;
|
|
146
146
|
}
|
|
147
|
-
buildTestCaseHookDefinitions(configs) {
|
|
148
|
-
return configs.map(({ code, line, options, uri }) => {
|
|
147
|
+
buildTestCaseHookDefinitions(configs, canonicalIds) {
|
|
148
|
+
return configs.map(({ code, line, options, uri }, index) => {
|
|
149
149
|
const wrappedCode = this.wrapCode({
|
|
150
150
|
code,
|
|
151
151
|
wrapperOptions: options.wrapperOptions,
|
|
152
152
|
});
|
|
153
153
|
return new test_case_hook_definition_1.default({
|
|
154
154
|
code: wrappedCode,
|
|
155
|
-
id: this.newId(),
|
|
155
|
+
id: canonicalIds ? canonicalIds[index] : this.newId(),
|
|
156
156
|
line,
|
|
157
157
|
options,
|
|
158
158
|
unwrappedCode: code,
|
|
@@ -192,10 +192,10 @@ class SupportCodeLibraryBuilder {
|
|
|
192
192
|
});
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
-
buildStepDefinitions() {
|
|
195
|
+
buildStepDefinitions(canonicalIds) {
|
|
196
196
|
const stepDefinitions = [];
|
|
197
197
|
const undefinedParameterTypes = [];
|
|
198
|
-
this.stepDefinitionConfigs.forEach(({ code, line, options, pattern, uri }) => {
|
|
198
|
+
this.stepDefinitionConfigs.forEach(({ code, line, options, pattern, uri }, index) => {
|
|
199
199
|
let expression;
|
|
200
200
|
if (typeof pattern === 'string') {
|
|
201
201
|
try {
|
|
@@ -222,7 +222,7 @@ class SupportCodeLibraryBuilder {
|
|
|
222
222
|
stepDefinitions.push(new step_definition_1.default({
|
|
223
223
|
code: wrappedCode,
|
|
224
224
|
expression,
|
|
225
|
-
id: this.newId(),
|
|
225
|
+
id: canonicalIds ? canonicalIds[index] : this.newId(),
|
|
226
226
|
line,
|
|
227
227
|
options,
|
|
228
228
|
pattern,
|
|
@@ -232,7 +232,7 @@ class SupportCodeLibraryBuilder {
|
|
|
232
232
|
});
|
|
233
233
|
return { stepDefinitions, undefinedParameterTypes };
|
|
234
234
|
}
|
|
235
|
-
finalize() {
|
|
235
|
+
finalize(canonicalIds) {
|
|
236
236
|
if (value_checker_1.doesNotHaveValue(this.definitionFunctionWrapper)) {
|
|
237
237
|
const definitionConfigs = lodash_1.default.chain([
|
|
238
238
|
this.afterTestCaseHookDefinitionConfigs,
|
|
@@ -245,12 +245,12 @@ class SupportCodeLibraryBuilder {
|
|
|
245
245
|
.value();
|
|
246
246
|
finalize_helpers_1.validateNoGeneratorFunctions({ cwd: this.cwd, definitionConfigs });
|
|
247
247
|
}
|
|
248
|
-
const stepDefinitionsResult = this.buildStepDefinitions();
|
|
248
|
+
const stepDefinitionsResult = this.buildStepDefinitions(canonicalIds === null || canonicalIds === void 0 ? void 0 : canonicalIds.stepDefinitionIds);
|
|
249
249
|
return {
|
|
250
|
-
afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.afterTestCaseHookDefinitionConfigs),
|
|
250
|
+
afterTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.afterTestCaseHookDefinitionConfigs, canonicalIds === null || canonicalIds === void 0 ? void 0 : canonicalIds.afterTestCaseHookDefinitionIds),
|
|
251
251
|
afterTestRunHookDefinitions: this.buildTestRunHookDefinitions(this.afterTestRunHookDefinitionConfigs),
|
|
252
252
|
afterTestStepHookDefinitions: this.buildTestStepHookDefinitions(this.afterTestStepHookDefinitionConfigs),
|
|
253
|
-
beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.beforeTestCaseHookDefinitionConfigs),
|
|
253
|
+
beforeTestCaseHookDefinitions: this.buildTestCaseHookDefinitions(this.beforeTestCaseHookDefinitionConfigs, canonicalIds === null || canonicalIds === void 0 ? void 0 : canonicalIds.beforeTestCaseHookDefinitionIds),
|
|
254
254
|
beforeTestRunHookDefinitions: this.buildTestRunHookDefinitions(this.beforeTestRunHookDefinitionConfigs),
|
|
255
255
|
beforeTestStepHookDefinitions: this.buildTestStepHookDefinitions(this.beforeTestStepHookDefinitionConfigs),
|
|
256
256
|
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,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AAC,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","sourceRoot":"","sources":["../../src/support_code_library_builder/index.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAsB;AACtB,mDAA6E;AAG7E,oGAAwE;AACxE,oGAAwE;AACxE,kGAAsE;AACtE,gFAAsD;AACtD,kDAAqD;AACrD,8EAAoD;AACpD,4DAA8B;AAE9B,yEAIuC;AACvC,oDAAkE;AAClE,yDAAiE;AAajE,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,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'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 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;
|
|
@@ -48,19 +46,19 @@ export interface IParameterTypeDefinition<T> {
|
|
|
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: RegExp\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 +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;QACpD,wBAAwB;wBACtB,UAAU,EAAE,iBAAiB,IAAK,YAAY;KACjD;IACD,kBAAkB,EAAE;wBAChB,UAAU,EAAE,gBAAgB,IAAK,iBAAiB;QACpD;YACE,UAA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AU,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"]}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"gherkin",
|
|
9
9
|
"tests"
|
|
10
10
|
],
|
|
11
|
-
"version": "7.
|
|
11
|
+
"version": "7.3.0",
|
|
12
12
|
"homepage": "https://github.com/cucumber/cucumber-js",
|
|
13
13
|
"author": "Julien Biezemans <jb@jbpros.com>",
|
|
14
14
|
"contributors": [
|
|
@@ -168,15 +168,14 @@
|
|
|
168
168
|
"node": ">=10"
|
|
169
169
|
},
|
|
170
170
|
"dependencies": {
|
|
171
|
-
"@cucumber/create-meta": "
|
|
172
|
-
"@cucumber/cucumber-expressions": "12.
|
|
173
|
-
"@cucumber/gherkin": "
|
|
174
|
-
"@cucumber/gherkin-streams": "
|
|
175
|
-
"@cucumber/html-formatter": "
|
|
176
|
-
"@cucumber/messages": "
|
|
177
|
-
"@cucumber/
|
|
178
|
-
"
|
|
179
|
-
"assertion-error-formatter": "3.0.0",
|
|
171
|
+
"@cucumber/create-meta": "^5.0.0",
|
|
172
|
+
"@cucumber/cucumber-expressions": "^12.1.1",
|
|
173
|
+
"@cucumber/gherkin": "^19.0.3",
|
|
174
|
+
"@cucumber/gherkin-streams": "^2.0.2",
|
|
175
|
+
"@cucumber/html-formatter": "^15.0.2",
|
|
176
|
+
"@cucumber/messages": "^16.0.1",
|
|
177
|
+
"@cucumber/tag-expressions": "^3.0.1",
|
|
178
|
+
"assertion-error-formatter": "^3.0.0",
|
|
180
179
|
"bluebird": "^3.7.2",
|
|
181
180
|
"capital-case": "^1.0.4",
|
|
182
181
|
"cli-table3": "^0.6.0",
|
|
@@ -204,57 +203,58 @@
|
|
|
204
203
|
"verror": "^1.10.0"
|
|
205
204
|
},
|
|
206
205
|
"devDependencies": {
|
|
207
|
-
"@cucumber/compatibility-kit": "
|
|
208
|
-
"@
|
|
209
|
-
"@
|
|
210
|
-
"@
|
|
206
|
+
"@cucumber/compatibility-kit": "7.0.0",
|
|
207
|
+
"@cucumber/message-streams": "2.0.0",
|
|
208
|
+
"@cucumber/query": "10.0.0",
|
|
209
|
+
"@sinonjs/fake-timers": "7.1.2",
|
|
210
|
+
"@types/bluebird": "3.5.35",
|
|
211
|
+
"@types/chai": "4.2.18",
|
|
211
212
|
"@types/dirty-chai": "2.0.2",
|
|
212
|
-
"@types/express": "4.17.
|
|
213
|
-
"@types/fs-extra": "9.0.
|
|
213
|
+
"@types/express": "4.17.12",
|
|
214
|
+
"@types/fs-extra": "9.0.11",
|
|
214
215
|
"@types/glob": "7.1.3",
|
|
215
|
-
"@types/lodash": "4.14.
|
|
216
|
+
"@types/lodash": "4.14.170",
|
|
216
217
|
"@types/mocha": "8.2.2",
|
|
217
218
|
"@types/mustache": "4.1.1",
|
|
218
219
|
"@types/mz": "2.7.3",
|
|
219
|
-
"@types/node": "14.
|
|
220
|
+
"@types/node": "14.17.1",
|
|
220
221
|
"@types/progress": "2.0.3",
|
|
221
222
|
"@types/resolve": "1.20.0",
|
|
222
|
-
"@types/semver": "7.3.
|
|
223
|
+
"@types/semver": "7.3.6",
|
|
223
224
|
"@types/sinon-chai": "3.2.5",
|
|
224
225
|
"@types/sinonjs__fake-timers": "6.0.2",
|
|
225
226
|
"@types/stream-buffers": "3.0.3",
|
|
226
227
|
"@types/tmp": "0.2.0",
|
|
227
228
|
"@types/verror": "1.10.4",
|
|
228
|
-
"@typescript-eslint/eslint-plugin": "4.
|
|
229
|
-
"@typescript-eslint/parser": "4.
|
|
229
|
+
"@typescript-eslint/eslint-plugin": "4.26.0",
|
|
230
|
+
"@typescript-eslint/parser": "4.26.0",
|
|
230
231
|
"chai": "4.3.4",
|
|
231
|
-
"chai-exclude": "2.0.
|
|
232
|
+
"chai-exclude": "2.0.3",
|
|
232
233
|
"coffeescript": "2.5.1",
|
|
233
234
|
"dependency-lint": "6.0.0",
|
|
234
235
|
"dirty-chai": "2.0.1",
|
|
235
|
-
"eslint": "7.
|
|
236
|
-
"eslint-config-prettier": "8.
|
|
236
|
+
"eslint": "7.27.0",
|
|
237
|
+
"eslint-config-prettier": "8.3.0",
|
|
237
238
|
"eslint-config-standard-with-typescript": "20.0.0",
|
|
238
|
-
"eslint-plugin-import": "2.
|
|
239
|
+
"eslint-plugin-import": "2.23.4",
|
|
239
240
|
"eslint-plugin-node": "11.1.0",
|
|
240
|
-
"eslint-plugin-prettier": "3.
|
|
241
|
-
"eslint-plugin-promise": "
|
|
241
|
+
"eslint-plugin-prettier": "3.4.0",
|
|
242
|
+
"eslint-plugin-promise": "5.1.0",
|
|
242
243
|
"eslint-plugin-standard": "4.1.0",
|
|
243
244
|
"express": "4.17.1",
|
|
244
245
|
"fs-extra": "9.1.0",
|
|
245
|
-
"mocha": "8.
|
|
246
|
+
"mocha": "8.4.0",
|
|
246
247
|
"mustache": "4.2.0",
|
|
247
|
-
"ndjson-parse": "1.0.4",
|
|
248
248
|
"nyc": "15.1.0",
|
|
249
|
-
"prettier": "2.
|
|
249
|
+
"prettier": "2.3.0",
|
|
250
250
|
"semver": "7.3.5",
|
|
251
|
-
"sinon": "
|
|
252
|
-
"sinon-chai": "3.
|
|
251
|
+
"sinon": "11.1.1",
|
|
252
|
+
"sinon-chai": "3.7.0",
|
|
253
253
|
"stream-buffers": "3.0.2",
|
|
254
254
|
"stream-to-string": "1.2.0",
|
|
255
255
|
"ts-node": "9.1.1",
|
|
256
256
|
"tsd": "0.14.0",
|
|
257
|
-
"typescript": "4.2
|
|
257
|
+
"typescript": "4.3.2"
|
|
258
258
|
},
|
|
259
259
|
"scripts": {
|
|
260
260
|
"build-local": "tsc -p tsconfig.node.json",
|