@cucumber/cucumber 10.8.0 → 11.0.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/lib/api/formatters.js +5 -4
- package/lib/api/formatters.js.map +1 -1
- package/lib/api/run_cucumber.js +8 -10
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/{runtime → assemble}/assemble_test_cases.d.ts +4 -6
- package/lib/{runtime → assemble}/assemble_test_cases.js +9 -8
- package/lib/assemble/assemble_test_cases.js.map +1 -0
- package/lib/assemble/index.d.ts +2 -0
- package/lib/assemble/index.js +19 -0
- package/lib/assemble/index.js.map +1 -0
- package/lib/assemble/types.d.ts +10 -0
- package/lib/{runtime/parallel/command_types.js → assemble/types.js} +1 -1
- package/lib/assemble/types.js.map +1 -0
- package/lib/cli/helpers.d.ts +0 -23
- package/lib/cli/helpers.js +1 -33
- package/lib/cli/helpers.js.map +1 -1
- package/lib/formatter/builtin/html.d.ts +5 -1
- package/lib/formatter/builtin/html.js +55 -4
- package/lib/formatter/builtin/html.js.map +1 -1
- package/lib/formatter/create_stream.d.ts +4 -1
- package/lib/formatter/create_stream.js +6 -2
- package/lib/formatter/create_stream.js.map +1 -1
- package/lib/formatter/index.d.ts +3 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/index.d.ts +0 -16
- package/lib/index.js +1 -16
- package/lib/index.js.map +1 -1
- package/lib/plugin/plugin_manager.d.ts +1 -1
- package/lib/plugin/plugin_manager.js +6 -2
- package/lib/plugin/plugin_manager.js.map +1 -1
- package/lib/plugin/types.d.ts +3 -0
- package/lib/plugin/types.js.map +1 -1
- package/lib/runtime/attachment_manager/index.d.ts +2 -0
- package/lib/runtime/attachment_manager/index.js +3 -0
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/coordinator.d.ts +16 -0
- package/lib/runtime/coordinator.js +42 -0
- package/lib/runtime/coordinator.js.map +1 -0
- package/lib/runtime/helpers.d.ts +3 -3
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +2 -41
- package/lib/runtime/index.js +14 -81
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/make_runtime.d.ts +17 -0
- package/lib/runtime/make_runtime.js +14 -0
- package/lib/runtime/make_runtime.js.map +1 -0
- package/lib/runtime/parallel/adapter.d.ts +48 -0
- package/lib/runtime/parallel/adapter.js +152 -0
- package/lib/runtime/parallel/adapter.js.map +1 -0
- package/lib/runtime/parallel/run_worker.js +2 -5
- package/lib/runtime/parallel/run_worker.js.map +1 -1
- package/lib/runtime/parallel/types.d.ts +32 -0
- package/lib/runtime/parallel/types.js +3 -0
- package/lib/runtime/parallel/types.js.map +1 -0
- package/lib/runtime/parallel/worker.d.ts +8 -9
- package/lib/runtime/parallel/worker.js +28 -44
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/serial/adapter.d.ts +13 -0
- package/lib/runtime/serial/adapter.js +24 -0
- package/lib/runtime/serial/adapter.js.map +1 -0
- package/lib/runtime/stopwatch.d.ts +2 -2
- package/lib/runtime/stopwatch.js +3 -4
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +2 -5
- package/lib/runtime/test_case_runner.js +7 -7
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/runtime/types.d.ts +17 -0
- package/lib/runtime/types.js +3 -0
- package/lib/runtime/types.js.map +1 -0
- package/lib/runtime/worker.d.ts +18 -0
- package/lib/runtime/worker.js +57 -0
- package/lib/runtime/worker.js.map +1 -0
- package/lib/support_code_library_builder/index.d.ts +2 -3
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +5 -0
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/support_code_library_builder/world.d.ts +5 -2
- package/lib/support_code_library_builder/world.js +3 -1
- package/lib/support_code_library_builder/world.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/lib/wrapper.mjs +0 -3
- package/package.json +6 -6
- package/lib/api/runtime.d.ts +0 -18
- package/lib/api/runtime.js +0 -33
- package/lib/api/runtime.js.map +0 -1
- package/lib/runtime/assemble_test_cases.js.map +0 -1
- package/lib/runtime/parallel/command_types.d.ts +0 -31
- package/lib/runtime/parallel/command_types.js.map +0 -1
- package/lib/runtime/parallel/coordinator.d.ts +0 -66
- package/lib/runtime/parallel/coordinator.js +0 -209
- package/lib/runtime/parallel/coordinator.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -8,11 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import * as messages from '@cucumber/messages';
|
|
10
10
|
import { default as _Cli } from './cli';
|
|
11
|
-
import * as cliHelpers from './cli/helpers';
|
|
12
11
|
import * as formatterHelpers from './formatter/helpers';
|
|
13
|
-
import { default as _PickleFilter } from './pickle_filter';
|
|
14
12
|
import * as parallelCanAssignHelpers from './support_code_library_builder/parallel_can_assign_helpers';
|
|
15
|
-
import { default as _Runtime } from './runtime';
|
|
16
13
|
export declare const version: string;
|
|
17
14
|
export { default as supportCodeLibraryBuilder } from './support_code_library_builder';
|
|
18
15
|
export { default as DataTable } from './models/data_table';
|
|
@@ -53,16 +50,3 @@ export { wrapPromiseWithTimeout } from './time';
|
|
|
53
50
|
* @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
54
51
|
*/
|
|
55
52
|
export declare const Cli: typeof _Cli;
|
|
56
|
-
/**
|
|
57
|
-
* @deprecated use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
58
|
-
*/
|
|
59
|
-
export declare const parseGherkinMessageStream: typeof cliHelpers.parseGherkinMessageStream;
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
62
|
-
*/
|
|
63
|
-
export declare const PickleFilter: typeof _PickleFilter;
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
66
|
-
*/
|
|
67
|
-
export declare const Runtime: typeof _Runtime;
|
|
68
|
-
export { INewRuntimeOptions, IRuntimeOptions } from './runtime';
|
package/lib/index.js
CHANGED
|
@@ -34,17 +34,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
34
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
35
|
};
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.
|
|
37
|
+
exports.Cli = exports.wrapPromiseWithTimeout = exports.Status = exports.parallelCanAssignHelpers = exports.context = exports.world = exports.World = exports.When = exports.Then = exports.setParallelCanAssign = exports.setWorldConstructor = exports.setDefinitionFunctionWrapper = exports.setDefaultTimeout = exports.Given = exports.defineParameterType = exports.defineStep = exports.BeforeStep = exports.BeforeAll = exports.Before = exports.AfterStep = exports.AfterAll = exports.After = exports.formatterHelpers = exports.UsageJsonFormatter = exports.UsageFormatter = exports.SummaryFormatter = exports.SnippetsFormatter = exports.RerunFormatter = exports.ProgressFormatter = exports.JsonFormatter = exports.FormatterBuilder = exports.Formatter = exports.TestCaseHookDefinition = exports.DataTable = exports.supportCodeLibraryBuilder = exports.version = void 0;
|
|
38
38
|
const node_util_1 = require("node:util");
|
|
39
39
|
const messages = __importStar(require("@cucumber/messages"));
|
|
40
40
|
const cli_1 = __importDefault(require("./cli"));
|
|
41
|
-
const cliHelpers = __importStar(require("./cli/helpers"));
|
|
42
41
|
const formatterHelpers = __importStar(require("./formatter/helpers"));
|
|
43
42
|
exports.formatterHelpers = formatterHelpers;
|
|
44
|
-
const pickle_filter_1 = __importDefault(require("./pickle_filter"));
|
|
45
43
|
const parallelCanAssignHelpers = __importStar(require("./support_code_library_builder/parallel_can_assign_helpers"));
|
|
46
44
|
exports.parallelCanAssignHelpers = parallelCanAssignHelpers;
|
|
47
|
-
const runtime_1 = __importDefault(require("./runtime"));
|
|
48
45
|
const support_code_library_builder_1 = __importDefault(require("./support_code_library_builder"));
|
|
49
46
|
const version_1 = require("./version");
|
|
50
47
|
// type version as string to avoid tripping api-extractor every release
|
|
@@ -106,16 +103,4 @@ Object.defineProperty(exports, "wrapPromiseWithTimeout", { enumerable: true, get
|
|
|
106
103
|
* @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
107
104
|
*/
|
|
108
105
|
exports.Cli = (0, node_util_1.deprecate)(cli_1.default, '`Cli` is deprecated, use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md');
|
|
109
|
-
/**
|
|
110
|
-
* @deprecated use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
111
|
-
*/
|
|
112
|
-
exports.parseGherkinMessageStream = (0, node_util_1.deprecate)(cliHelpers.parseGherkinMessageStream, '`parseGherkinMessageStream` is deprecated, use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md');
|
|
113
|
-
/**
|
|
114
|
-
* @deprecated use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
115
|
-
*/
|
|
116
|
-
exports.PickleFilter = (0, node_util_1.deprecate)(pickle_filter_1.default, '`PickleFilter` is deprecated, use `loadSources` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md');
|
|
117
|
-
/**
|
|
118
|
-
* @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
|
|
119
|
-
*/
|
|
120
|
-
exports.Runtime = (0, node_util_1.deprecate)(runtime_1.default, '`Runtime` is deprecated, use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md');
|
|
121
106
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot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AC,MAAM,CAAA;AACvB,QAAA,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;AAC7B,QAAA,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;AAC/B,QAAA,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;AAC/B,QAAA,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAA;AACjD,QAAA,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;AACrB,QAAA,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAA;AAC7C,QAAA,4BAA4B,GAAG,OAAO,CAAC,4BAA4B,CAAA;AACnE,QAAA,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAA;AACjD,QAAA,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAA;AACnD,QAAA,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;AACnB,QAAA,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;AAChC,8DAI6C;AAH3C,+GAAA,OAAO,OAAS;AAKlB,yCAA8E;AAArE,8FAAA,UAAU,OAAS;AAAE,gGAAA,YAAY,OAAW;AAOxC,QAAA,MAAM,GAAG,QAAQ,CAAC,oBAAoB,CAAA;AAEnD,eAAe;AACf,+BAA+C;AAAtC,8GAAA,sBAAsB,OAAA;AAE/B,aAAa;AACb;;GAEG;AACU,QAAA,GAAG,GAAG,IAAA,qBAAS,EAC1B,aAAI,EACJ,4HAA4H,CAC7H,CAAA","sourcesContent":["/**\n * User code functions and helpers\n *\n * @packageDocumentation\n * @module (root)\n * @remarks\n * These docs cover the functions and helpers for user code registration and test setup. The entry point is `@cucumber/cucumber`.\n */\n\nimport { deprecate } from 'node:util'\nimport * as messages from '@cucumber/messages'\nimport { default as _Cli } from './cli'\nimport * as formatterHelpers from './formatter/helpers'\nimport * as parallelCanAssignHelpers from './support_code_library_builder/parallel_can_assign_helpers'\nimport supportCodeLibraryBuilder from './support_code_library_builder'\nimport { version as _version } from './version'\n\n// type version as string to avoid tripping api-extractor every release\nexport const version = _version as string\n\n// Top level\nexport { default as supportCodeLibraryBuilder } from './support_code_library_builder'\nexport { default as DataTable } from './models/data_table'\nexport { default as TestCaseHookDefinition } from './models/test_case_hook_definition'\n\n// Formatters\nexport { default as Formatter, IFormatterOptions } from './formatter'\nexport { default as FormatterBuilder } from './formatter/builder'\nexport { default as JsonFormatter } from './formatter/json_formatter'\nexport { default as ProgressFormatter } from './formatter/progress_formatter'\nexport { default as RerunFormatter } from './formatter/rerun_formatter'\nexport { default as SnippetsFormatter } from './formatter/snippets_formatter'\nexport { default as SummaryFormatter } from './formatter/summary_formatter'\nexport { default as UsageFormatter } from './formatter/usage_formatter'\nexport { default as UsageJsonFormatter } from './formatter/usage_json_formatter'\nexport { formatterHelpers }\n\n// Support Code Functions\nconst { methods } = supportCodeLibraryBuilder\nexport const After = methods.After\nexport const AfterAll = methods.AfterAll\nexport const AfterStep = methods.AfterStep\nexport const Before = methods.Before\nexport const BeforeAll = methods.BeforeAll\nexport const BeforeStep = methods.BeforeStep\nexport const defineStep = methods.defineStep\nexport const defineParameterType = methods.defineParameterType\nexport const Given = methods.Given\nexport const setDefaultTimeout = methods.setDefaultTimeout\nexport const setDefinitionFunctionWrapper = methods.setDefinitionFunctionWrapper\nexport const setWorldConstructor = methods.setWorldConstructor\nexport const setParallelCanAssign = methods.setParallelCanAssign\nexport const Then = methods.Then\nexport const When = methods.When\nexport {\n default as World,\n IWorld,\n IWorldOptions,\n} from './support_code_library_builder/world'\nexport { IContext } from './support_code_library_builder/context'\nexport { worldProxy as world, contextProxy as context } from './runtime/scope'\nexport { parallelCanAssignHelpers }\n\nexport {\n ITestCaseHookParameter,\n ITestStepHookParameter,\n} from './support_code_library_builder/types'\nexport const Status = messages.TestStepResultStatus\n\n// Time helpers\nexport { wrapPromiseWithTimeout } from './time'\n\n// Deprecated\n/**\n * @deprecated use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md\n */\nexport const Cli = deprecate(\n _Cli,\n '`Cli` is deprecated, use `runCucumber` instead; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md'\n)\n"]}
|
|
@@ -5,7 +5,7 @@ export declare class PluginManager {
|
|
|
5
5
|
private handlers;
|
|
6
6
|
private cleanupFns;
|
|
7
7
|
private register;
|
|
8
|
-
initFormatter<OptionsType>(plugin: FormatterPlugin<OptionsType>, options: OptionsType, write: (buffer: string | Uint8Array) => void): Promise<void>;
|
|
8
|
+
initFormatter<OptionsType>(plugin: FormatterPlugin<OptionsType>, options: OptionsType, logger: ILogger, write: (buffer: string | Uint8Array) => void, directory?: string): Promise<void>;
|
|
9
9
|
initCoordinator<OptionsType>(operation: Operation, plugin: InternalPlugin<OptionsType>, options: OptionsType, logger: ILogger, environment: Required<IRunEnvironment>): Promise<void>;
|
|
10
10
|
emit<K extends CoordinatorPluginEventKey>(event: K, value: CoordinatorPluginEventValues[K]): void;
|
|
11
11
|
transform<K extends CoordinatorPluginTransformEventKey>(event: K, value: CoordinatorPluginEventValues[K]): Promise<CoordinatorPluginEventValues[K]>;
|
|
@@ -12,11 +12,15 @@ class PluginManager {
|
|
|
12
12
|
async register(event, handler) {
|
|
13
13
|
this.handlers[event]?.push(handler);
|
|
14
14
|
}
|
|
15
|
-
async initFormatter(plugin, options, write) {
|
|
15
|
+
async initFormatter(plugin, options, logger, write, directory) {
|
|
16
16
|
const cleanupFn = await plugin.formatter({
|
|
17
17
|
on: (key, handler) => this.register(key, handler),
|
|
18
|
-
options
|
|
18
|
+
options: plugin.optionsKey
|
|
19
|
+
? options[plugin.optionsKey] ?? {}
|
|
20
|
+
: options,
|
|
21
|
+
logger,
|
|
19
22
|
write,
|
|
23
|
+
directory,
|
|
20
24
|
});
|
|
21
25
|
if (typeof cleanupFn === 'function') {
|
|
22
26
|
this.cleanupFns.push(cleanupFn);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin_manager.js","sourceRoot":"","sources":["../../src/plugin/plugin_manager.ts"],"names":[],"mappings":";;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ordinatorPluginEventHandler,\n InternalPlugin,\n PluginCleanup,\n CoordinatorPluginEventValues,\n CoordinatorPluginEventKey,\n CoordinatorPluginTransformEventKey,\n Operation,\n FormatterPlugin,\n} from './types'\n\ntype HandlerRegistry = {\n [K in CoordinatorPluginEventKey]: Array<CoordinatorPluginEventHandler<K>>\n}\n\nexport class PluginManager {\n private handlers: HandlerRegistry = {\n message: [],\n 'paths:resolve': [],\n 'pickles:filter': [],\n 'pickles:order': [],\n }\n private cleanupFns: PluginCleanup[] = []\n\n private async register<K extends CoordinatorPluginEventKey>(\n event: K,\n handler: CoordinatorPluginEventHandler<K>\n ) {\n this.handlers[event]?.push(handler)\n }\n\n async initFormatter<OptionsType>(\n plugin: FormatterPlugin<OptionsType>,\n options: OptionsType,\n logger: ILogger,\n write: (buffer: string | Uint8Array) => void,\n directory?: string\n ) {\n const cleanupFn = await plugin.formatter({\n on: (key, handler) => this.register(key, handler),\n options: plugin.optionsKey\n ? (options as any)[plugin.optionsKey] ?? ({} as OptionsType)\n : options,\n logger,\n write,\n directory,\n })\n if (typeof cleanupFn === 'function') {\n this.cleanupFns.push(cleanupFn)\n }\n }\n\n async initCoordinator<OptionsType>(\n operation: Operation,\n plugin: InternalPlugin<OptionsType>,\n options: OptionsType,\n logger: ILogger,\n environment: Required<IRunEnvironment>\n ) {\n const cleanupFn = await plugin.coordinator({\n operation,\n on: this.register.bind(this),\n options,\n logger,\n environment,\n })\n if (typeof cleanupFn === 'function') {\n this.cleanupFns.push(cleanupFn)\n }\n }\n\n emit<K extends CoordinatorPluginEventKey>(\n event: K,\n value: CoordinatorPluginEventValues[K]\n ): void {\n this.handlers[event].forEach((handler) => handler(value))\n }\n\n async transform<K extends CoordinatorPluginTransformEventKey>(\n event: K,\n value: CoordinatorPluginEventValues[K]\n ): Promise<CoordinatorPluginEventValues[K]> {\n let transformed = value\n for (const handler of this.handlers[event]) {\n const returned = await handler(transformed)\n if (typeof returned !== 'undefined') {\n transformed = returned\n }\n }\n return transformed\n }\n\n async cleanup(): Promise<void> {\n for (const cleanupFn of this.cleanupFns) {\n await cleanupFn()\n }\n }\n}\n"]}
|
package/lib/plugin/types.d.ts
CHANGED
|
@@ -39,11 +39,14 @@ export interface InternalPlugin<OptionsType = any> {
|
|
|
39
39
|
export interface FormatterPluginContext<OptionsType> {
|
|
40
40
|
on: (key: 'message', handler: (value: Envelope) => void) => void;
|
|
41
41
|
options: OptionsType;
|
|
42
|
+
logger: ILogger;
|
|
42
43
|
write: (buffer: string | Uint8Array) => void;
|
|
44
|
+
directory?: string;
|
|
43
45
|
}
|
|
44
46
|
export type FormatterPluginFunction<OptionsType> = (context: FormatterPluginContext<OptionsType>) => Promisable<PluginCleanup | void>;
|
|
45
47
|
export interface FormatterPlugin<OptionsType = any> {
|
|
46
48
|
type: 'formatter';
|
|
47
49
|
formatter: FormatterPluginFunction<OptionsType>;
|
|
48
50
|
documentation: string;
|
|
51
|
+
optionsKey?: string;
|
|
49
52
|
}
|
package/lib/plugin/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Envelope } from '@cucumber/messages'\nimport { ArrayValues, Promisable } from 'type-fest'\nimport { IRunEnvironment } from '../api'\nimport { ILogger } from '../logger'\nimport { IFilterablePickle } from '../filter'\nimport { IResolvedPaths } from '../paths'\nimport { coordinatorTransformKeys, coordinatorVoidKeys } from './events'\n\nexport type Operation = 'loadSources' | 'loadSupport' | 'runCucumber'\n\nexport type CoordinatorPluginVoidEventKey = ArrayValues<\n typeof coordinatorVoidKeys\n>\nexport type CoordinatorPluginTransformEventKey = ArrayValues<\n typeof coordinatorTransformKeys\n>\nexport type CoordinatorPluginEventKey =\n | CoordinatorPluginVoidEventKey\n | CoordinatorPluginTransformEventKey\n\nexport type CoordinatorPluginEventValues = {\n // void\n message: Readonly<Envelope>\n 'paths:resolve': Readonly<IResolvedPaths>\n // transform\n 'pickles:filter': Readonly<Array<IFilterablePickle>>\n 'pickles:order': Readonly<Array<IFilterablePickle>>\n}\n\nexport type CoordinatorPluginEventHandler<K extends CoordinatorPluginEventKey> =\n (\n value: CoordinatorPluginEventValues[K]\n ) => K extends CoordinatorPluginTransformEventKey\n ? Promisable<CoordinatorPluginEventValues[K]>\n : void\n\nexport interface CoordinatorPluginContext<OptionsType> {\n operation: Operation\n on: <EventKey extends CoordinatorPluginEventKey>(\n event: EventKey,\n handler: CoordinatorPluginEventHandler<EventKey>\n ) => void\n options: OptionsType\n logger: ILogger\n environment: Required<IRunEnvironment>\n}\n\nexport type CoordinatorPluginFunction<OptionsType> = (\n context: CoordinatorPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport type PluginCleanup = () => Promisable<void>\n\n/**\n * A plugin to implement Cucumber built-in functionality.\n *\n * Uses the same events and mechanisms as user-authored plugins, but is free to require configuration and context from\n * inside of Cucumber as its `options`, whereas user-authored plugins will be limited to `pluginOptions` from the\n * project configuration.\n */\nexport interface InternalPlugin<OptionsType = any> {\n type: 'plugin'\n coordinator: CoordinatorPluginFunction<OptionsType>\n}\n\nexport interface FormatterPluginContext<OptionsType> {\n on: (key: 'message', handler: (value: Envelope) => void) => void\n options: OptionsType\n write: (buffer: string | Uint8Array) => void\n}\n\nexport type FormatterPluginFunction<OptionsType> = (\n context: FormatterPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport interface FormatterPlugin<OptionsType = any> {\n type: 'formatter'\n formatter: FormatterPluginFunction<OptionsType>\n documentation: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Envelope } from '@cucumber/messages'\nimport { ArrayValues, Promisable } from 'type-fest'\nimport { IRunEnvironment } from '../api'\nimport { ILogger } from '../logger'\nimport { IFilterablePickle } from '../filter'\nimport { IResolvedPaths } from '../paths'\nimport { coordinatorTransformKeys, coordinatorVoidKeys } from './events'\n\nexport type Operation = 'loadSources' | 'loadSupport' | 'runCucumber'\n\nexport type CoordinatorPluginVoidEventKey = ArrayValues<\n typeof coordinatorVoidKeys\n>\nexport type CoordinatorPluginTransformEventKey = ArrayValues<\n typeof coordinatorTransformKeys\n>\nexport type CoordinatorPluginEventKey =\n | CoordinatorPluginVoidEventKey\n | CoordinatorPluginTransformEventKey\n\nexport type CoordinatorPluginEventValues = {\n // void\n message: Readonly<Envelope>\n 'paths:resolve': Readonly<IResolvedPaths>\n // transform\n 'pickles:filter': Readonly<Array<IFilterablePickle>>\n 'pickles:order': Readonly<Array<IFilterablePickle>>\n}\n\nexport type CoordinatorPluginEventHandler<K extends CoordinatorPluginEventKey> =\n (\n value: CoordinatorPluginEventValues[K]\n ) => K extends CoordinatorPluginTransformEventKey\n ? Promisable<CoordinatorPluginEventValues[K]>\n : void\n\nexport interface CoordinatorPluginContext<OptionsType> {\n operation: Operation\n on: <EventKey extends CoordinatorPluginEventKey>(\n event: EventKey,\n handler: CoordinatorPluginEventHandler<EventKey>\n ) => void\n options: OptionsType\n logger: ILogger\n environment: Required<IRunEnvironment>\n}\n\nexport type CoordinatorPluginFunction<OptionsType> = (\n context: CoordinatorPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport type PluginCleanup = () => Promisable<void>\n\n/**\n * A plugin to implement Cucumber built-in functionality.\n *\n * Uses the same events and mechanisms as user-authored plugins, but is free to require configuration and context from\n * inside of Cucumber as its `options`, whereas user-authored plugins will be limited to `pluginOptions` from the\n * project configuration.\n */\nexport interface InternalPlugin<OptionsType = any> {\n type: 'plugin'\n coordinator: CoordinatorPluginFunction<OptionsType>\n}\n\nexport interface FormatterPluginContext<OptionsType> {\n on: (key: 'message', handler: (value: Envelope) => void) => void\n options: OptionsType\n logger: ILogger\n write: (buffer: string | Uint8Array) => void\n directory?: string\n}\n\nexport type FormatterPluginFunction<OptionsType> = (\n context: FormatterPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport interface FormatterPlugin<OptionsType = any> {\n type: 'formatter'\n formatter: FormatterPluginFunction<OptionsType>\n documentation: string\n optionsKey?: string\n}\n"]}
|
|
@@ -22,10 +22,12 @@ export type ICreateStreamAttachment = (data: Readable, mediaTypeOrOptions: strin
|
|
|
22
22
|
export type ICreateStreamAttachmentWithCallback = (data: Readable, mediaTypeOrOptions: string | ICreateAttachmentOptions, callback: () => void) => void;
|
|
23
23
|
export type ICreateAttachment = ICreateStringAttachment & ICreateBufferAttachment & ICreateStreamAttachment & ICreateStreamAttachmentWithCallback;
|
|
24
24
|
export type ICreateLog = (text: string) => void;
|
|
25
|
+
export type ICreateLink = (text: string) => void;
|
|
25
26
|
export default class AttachmentManager {
|
|
26
27
|
private readonly onAttachment;
|
|
27
28
|
constructor(onAttachment: IAttachFunction);
|
|
28
29
|
log(text: string): void | Promise<void>;
|
|
30
|
+
link(...url: string[]): void | Promise<void>;
|
|
29
31
|
create(data: Buffer | Readable | string, mediaTypeOrOptions?: string | ICreateAttachmentOptions, callback?: () => void): void | Promise<void>;
|
|
30
32
|
createBufferAttachment(data: Buffer, mediaType: string, fileName?: string): void;
|
|
31
33
|
createStreamAttachment(data: Readable, mediaType: string, fileName?: string, callback?: () => void): void | Promise<void>;
|
|
@@ -37,6 +37,9 @@ class AttachmentManager {
|
|
|
37
37
|
log(text) {
|
|
38
38
|
return this.create(text, 'text/x.cucumber.log+plain');
|
|
39
39
|
}
|
|
40
|
+
link(...url) {
|
|
41
|
+
return this.create(url.join('\n'), 'text/uri-list');
|
|
42
|
+
}
|
|
40
43
|
create(data, mediaTypeOrOptions, callback) {
|
|
41
44
|
const options = normaliseOptions(mediaTypeOrOptions);
|
|
42
45
|
if (Buffer.isBuffer(data)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/attachment_manager/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0DAAgC;AA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CAAC,CAAA;YACrB,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;gBAClB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;gBACxE,OAAO,EAAE,CAAA;YACX,CAAC,CAAC,CAAA;YACF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;QACF,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,EAAE;YAC3B,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;SACjC;aAAM;YACL,OAAO,OAAO,CAAA;SACf;IACH,CAAC;IAED,sBAAsB,CACpB,IAAY,EACZ,KAAuB,EACvB,QAAiB;QAEjB,IAAI,CAAC,YAAY,CAAC;YAChB,IAAI;YACJ,KAAK;YACL,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClC,CAAC,CAAA;IACJ,CAAC;CACF;AApHD,oCAoHC;AAED,SAAS,gBAAgB,CACvB,kBAAsD;IAEtD,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,EAAE,CAAA;KACV;IACD,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE;QAC1C,OAAO;YACL,SAAS,EAAE,kBAAkB;SAC9B,CAAA;KACF;IACD,OAAO,kBAAkB,CAAA;AAC3B,CAAC","sourcesContent":["import { Readable } from 'node:stream'\nimport isStream from 'is-stream'\nimport * as messages from '@cucumber/messages'\nimport { doesHaveValue, doesNotHaveValue } from '../../value_checker'\n\nexport interface IAttachmentMedia {\n encoding: messages.AttachmentContentEncoding\n contentType: string\n}\n\nexport interface IAttachment {\n data: string\n media: IAttachmentMedia\n fileName?: string\n}\n\nexport type IAttachFunction = (attachment: IAttachment) => void\n\nexport interface ICreateAttachmentOptions {\n mediaType: string\n fileName?: string\n}\nexport type ICreateStringAttachment = (\n data: string,\n mediaTypeOrOptions?: string | ICreateAttachmentOptions\n) => void\nexport type ICreateBufferAttachment = (\n data: Buffer,\n mediaTypeOrOptions: string | ICreateAttachmentOptions\n) => void\nexport type ICreateStreamAttachment = (\n data: Readable,\n mediaTypeOrOptions: string | ICreateAttachmentOptions\n) => Promise<void>\nexport type ICreateStreamAttachmentWithCallback = (\n data: Readable,\n mediaTypeOrOptions: string | ICreateAttachmentOptions,\n callback: () => void\n) => void\nexport type ICreateAttachment = ICreateStringAttachment &\n ICreateBufferAttachment &\n ICreateStreamAttachment &\n ICreateStreamAttachmentWithCallback\nexport type ICreateLog = (text: string) => void\nexport type ICreateLink = (text: string) => void\n\nexport default class AttachmentManager {\n private readonly onAttachment: IAttachFunction\n\n constructor(onAttachment: IAttachFunction) {\n this.onAttachment = onAttachment\n }\n\n log(text: string): void | Promise<void> {\n return this.create(text, 'text/x.cucumber.log+plain')\n }\n\n link(...url: string[]): void | Promise<void> {\n return this.create(url.join('\\n'), 'text/uri-list')\n }\n\n create(\n data: Buffer | Readable | string,\n mediaTypeOrOptions?: string | ICreateAttachmentOptions,\n callback?: () => void\n ): void | Promise<void> {\n const options = normaliseOptions(mediaTypeOrOptions)\n if (Buffer.isBuffer(data)) {\n if (doesNotHaveValue(options.mediaType)) {\n throw Error('Buffer attachments must specify a media type')\n }\n this.createBufferAttachment(data, options.mediaType, options.fileName)\n } else if (isStream.readable(data)) {\n if (doesNotHaveValue(options.mediaType)) {\n throw Error('Stream attachments must specify a media type')\n }\n return this.createStreamAttachment(\n data,\n options.mediaType,\n options.fileName,\n callback\n )\n } else if (typeof data === 'string') {\n if (doesNotHaveValue(options.mediaType)) {\n options.mediaType = 'text/plain'\n }\n if (options.mediaType.startsWith('base64:')) {\n this.createStringAttachment(\n data,\n {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: options.mediaType.replace('base64:', ''),\n },\n options.fileName\n )\n } else {\n this.createStringAttachment(\n data,\n {\n encoding: messages.AttachmentContentEncoding.IDENTITY,\n contentType: options.mediaType,\n },\n options.fileName\n )\n }\n } else {\n throw Error(\n 'Invalid attachment data: must be a buffer, readable stream, or string'\n )\n }\n }\n\n createBufferAttachment(\n data: Buffer,\n mediaType: string,\n fileName?: string\n ): void {\n this.createStringAttachment(\n data.toString('base64'),\n {\n encoding: messages.AttachmentContentEncoding.BASE64,\n contentType: mediaType,\n },\n fileName\n )\n }\n\n createStreamAttachment(\n data: Readable,\n mediaType: string,\n fileName?: string,\n callback?: () => void\n ): void | Promise<void> {\n const promise = new Promise<void>((resolve, reject) => {\n const buffers: Uint8Array[] = []\n data.on('data', (chunk) => {\n buffers.push(chunk)\n })\n data.on('end', () => {\n this.createBufferAttachment(Buffer.concat(buffers), mediaType, fileName)\n resolve()\n })\n data.on('error', reject)\n })\n if (doesHaveValue(callback)) {\n promise.then(callback, callback)\n } else {\n return promise\n }\n }\n\n createStringAttachment(\n data: string,\n media: IAttachmentMedia,\n fileName?: string\n ): void {\n this.onAttachment({\n data,\n media,\n ...(fileName ? { fileName } : {}),\n })\n }\n}\n\nfunction normaliseOptions(\n mediaTypeOrOptions?: string | ICreateAttachmentOptions\n): Partial<ICreateAttachmentOptions> {\n if (!mediaTypeOrOptions) {\n return {}\n }\n if (typeof mediaTypeOrOptions === 'string') {\n return {\n mediaType: mediaTypeOrOptions,\n }\n }\n return mediaTypeOrOptions\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
4
|
+
import { SourcedPickle } from '../assemble';
|
|
5
|
+
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
6
|
+
import { RuntimeAdapter } from './types';
|
|
7
|
+
import { Runtime } from './index';
|
|
8
|
+
export declare class Coordinator implements Runtime {
|
|
9
|
+
private eventBroadcaster;
|
|
10
|
+
private newId;
|
|
11
|
+
private sourcedPickles;
|
|
12
|
+
private supportCodeLibrary;
|
|
13
|
+
private adapter;
|
|
14
|
+
constructor(eventBroadcaster: EventEmitter, newId: IdGenerator.NewId, sourcedPickles: ReadonlyArray<SourcedPickle>, supportCodeLibrary: SupportCodeLibrary, adapter: RuntimeAdapter);
|
|
15
|
+
run(): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Coordinator = void 0;
|
|
4
|
+
const assemble_1 = require("../assemble");
|
|
5
|
+
const stopwatch_1 = require("./stopwatch");
|
|
6
|
+
class Coordinator {
|
|
7
|
+
eventBroadcaster;
|
|
8
|
+
newId;
|
|
9
|
+
sourcedPickles;
|
|
10
|
+
supportCodeLibrary;
|
|
11
|
+
adapter;
|
|
12
|
+
constructor(eventBroadcaster, newId, sourcedPickles, supportCodeLibrary, adapter) {
|
|
13
|
+
this.eventBroadcaster = eventBroadcaster;
|
|
14
|
+
this.newId = newId;
|
|
15
|
+
this.sourcedPickles = sourcedPickles;
|
|
16
|
+
this.supportCodeLibrary = supportCodeLibrary;
|
|
17
|
+
this.adapter = adapter;
|
|
18
|
+
}
|
|
19
|
+
async run() {
|
|
20
|
+
this.eventBroadcaster.emit('envelope', {
|
|
21
|
+
testRunStarted: {
|
|
22
|
+
timestamp: (0, stopwatch_1.timestamp)(),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
const assembledTestCases = await (0, assemble_1.assembleTestCases)({
|
|
26
|
+
eventBroadcaster: this.eventBroadcaster,
|
|
27
|
+
newId: this.newId,
|
|
28
|
+
sourcedPickles: this.sourcedPickles,
|
|
29
|
+
supportCodeLibrary: this.supportCodeLibrary,
|
|
30
|
+
});
|
|
31
|
+
const success = await this.adapter.run(assembledTestCases);
|
|
32
|
+
this.eventBroadcaster.emit('envelope', {
|
|
33
|
+
testRunFinished: {
|
|
34
|
+
timestamp: (0, stopwatch_1.timestamp)(),
|
|
35
|
+
success,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return success;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.Coordinator = Coordinator;
|
|
42
|
+
//# sourceMappingURL=coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../src/runtime/coordinator.ts"],"names":[],"mappings":";;;AAEA,0CAA8D;AAG9D,2CAAuC;AAGvC,MAAa,WAAW;IAEZ;IACA;IACA;IACA;IACA;IALV,YACU,gBAA8B,EAC9B,KAAwB,EACxB,cAA4C,EAC5C,kBAAsC,EACtC,OAAuB;QAJvB,qBAAgB,GAAhB,gBAAgB,CAAc;QAC9B,UAAK,GAAL,KAAK,CAAmB;QACxB,mBAAc,GAAd,cAAc,CAA8B;QAC5C,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,YAAO,GAAP,OAAO,CAAgB;IAC9B,CAAC;IAEJ,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE;YACrC,cAAc,EAAE;gBACd,SAAS,EAAE,IAAA,qBAAS,GAAE;aACvB;SACiB,CAAC,CAAA;QAErB,MAAM,kBAAkB,GAAG,MAAM,IAAA,4BAAiB,EAAC;YACjD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC5C,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;QAE1D,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE;YACrC,eAAe,EAAE;gBACf,SAAS,EAAE,IAAA,qBAAS,GAAE;gBACtB,OAAO;aACR;SACiB,CAAC,CAAA;QAErB,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAlCD,kCAkCC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { Envelope, IdGenerator } from '@cucumber/messages'\nimport { assembleTestCases, SourcedPickle } from '../assemble'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { RuntimeAdapter } from './types'\nimport { timestamp } from './stopwatch'\nimport { Runtime } from './index'\n\nexport class Coordinator implements Runtime {\n constructor(\n private eventBroadcaster: EventEmitter,\n private newId: IdGenerator.NewId,\n private sourcedPickles: ReadonlyArray<SourcedPickle>,\n private supportCodeLibrary: SupportCodeLibrary,\n private adapter: RuntimeAdapter\n ) {}\n\n async run(): Promise<boolean> {\n this.eventBroadcaster.emit('envelope', {\n testRunStarted: {\n timestamp: timestamp(),\n },\n } satisfies Envelope)\n\n const assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n sourcedPickles: this.sourcedPickles,\n supportCodeLibrary: this.supportCodeLibrary,\n })\n\n const success = await this.adapter.run(assembledTestCases)\n\n this.eventBroadcaster.emit('envelope', {\n testRunFinished: {\n timestamp: timestamp(),\n success,\n },\n } satisfies Envelope)\n\n return success\n }\n}\n"]}
|
package/lib/runtime/helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as messages from '@cucumber/messages';
|
|
2
2
|
import StepDefinition from '../models/step_definition';
|
|
3
|
-
import {
|
|
3
|
+
import { RuntimeOptions } from '.';
|
|
4
4
|
export declare function getAmbiguousStepException(stepDefinitions: StepDefinition[]): string;
|
|
5
|
-
export declare function retriesForPickle(pickle: messages.Pickle, options:
|
|
6
|
-
export declare function shouldCauseFailure(status: messages.TestStepResultStatus, options:
|
|
5
|
+
export declare function retriesForPickle(pickle: messages.Pickle, options: RuntimeOptions): number;
|
|
6
|
+
export declare function shouldCauseFailure(status: messages.TestStepResultStatus, options: RuntimeOptions): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA8B;AAC9B,kEAAwC;AACxC,6DAA8C;AAC9C,4EAAsE;AACtE,oDAAkD;AAIlD,SAAgB,yBAAyB,CACvC,eAAiC;IAEjC,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;QACtB,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,aAAa,EAAE,EAAE;YACjB,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,GAAG,EAAE,EAAE;YACP,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,EAAE;YACT,WAAW,EAAE,EAAE;YACf,GAAG,EAAE,EAAE;YACP,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,EAAE;YACb,WAAW,EAAE,EAAE;SAChB;QACD,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,cAAc,EAAE,CAAC;YACjB,eAAe,EAAE,CAAC;SACnB;KACF,CAAC,CAAA;IACF,KAAK,CAAC,IAAI,CACR,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;QACxC,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAA;QACjD,OAAO,CAAC,OAAO,EAAE,IAAA,iCAAc,EAAC,cAAc,CAAC,CAAC,CAAA;IAClD,CAAC,CAAC,CACH,CAAA;IACD,OAAO,GAAG,kCAAkC,GAAG,IAAI,GAAG,IAAA,uBAAY,EAChE,KAAK,CAAC,QAAQ,EAAE,EAChB,CAAC,CACF,EAAE,CAAA;AACL,CAAC;AArCD,8DAqCC;AAED,SAAgB,gBAAgB,CAC9B,MAAuB,EACvB,
|
|
1
|
+
{"version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AC,CAAA;KACT;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAA;IAC7B,IAAI,OAAO,KAAK,CAAC,EAAE;QACjB,OAAO,CAAC,CAAA;KACT;IACD,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;IAC7C,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,OAAO,CAAA;KACf;IACD,MAAM,eAAe,GAAG,IAAI,+BAAe,CAAC,cAAc,CAAC,CAAA;IAC3D,IAAI,eAAe,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE;QACpD,OAAO,OAAO,CAAA;KACf;IACD,OAAO,CAAC,CAAA;AACV,CAAC;AApBD,4CAoBC;AAED,SAAgB,kBAAkB,CAChC,MAAqC,EACrC,OAAuB;IAEvB,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,OAAO,KAAK,CAAA;KACb;IACD,MAAM,eAAe,GAAoC;QACvD,QAAQ,CAAC,oBAAoB,CAAC,SAAS;QACvC,QAAQ,CAAC,oBAAoB,CAAC,MAAM;QACpC,QAAQ,CAAC,oBAAoB,CAAC,SAAS;KACxC,CAAA;IACD,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;KAC5D;IACD,OAAO,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACzC,CAAC;AAhBD,gDAgBC","sourcesContent":["import Table from 'cli-table3'\nimport indentString from 'indent-string'\nimport * as messages from '@cucumber/messages'\nimport { formatLocation } from '../formatter/helpers/location_helpers'\nimport { PickleTagFilter } from '../pickle_filter'\nimport StepDefinition from '../models/step_definition'\nimport { RuntimeOptions } from '.'\n\nexport function getAmbiguousStepException(\n stepDefinitions: StepDefinition[]\n): string {\n const table = new Table({\n chars: {\n bottom: '',\n 'bottom-left': '',\n 'bottom-mid': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n middle: ' - ',\n right: '',\n 'right-mid': '',\n top: '',\n 'top-left': '',\n 'top-mid': '',\n 'top-right': '',\n },\n style: {\n border: [],\n 'padding-left': 0,\n 'padding-right': 0,\n },\n })\n table.push(\n ...stepDefinitions.map((stepDefinition) => {\n const pattern = stepDefinition.pattern.toString()\n return [pattern, formatLocation(stepDefinition)]\n })\n )\n return `${'Multiple step definitions match:' + '\\n'}${indentString(\n table.toString(),\n 2\n )}`\n}\n\nexport function retriesForPickle(\n pickle: messages.Pickle,\n options: RuntimeOptions\n): number {\n if (!options.retry) {\n return 0\n }\n const retries = options.retry\n if (retries === 0) {\n return 0\n }\n const retryTagFilter = options.retryTagFilter\n if (!retryTagFilter) {\n return retries\n }\n const pickleTagFilter = new PickleTagFilter(retryTagFilter)\n if (pickleTagFilter.matchesAllTagExpressions(pickle)) {\n return retries\n }\n return 0\n}\n\nexport function shouldCauseFailure(\n status: messages.TestStepResultStatus,\n options: RuntimeOptions\n): boolean {\n if (options.dryRun) {\n return false\n }\n const failureStatuses: messages.TestStepResultStatus[] = [\n messages.TestStepResultStatus.AMBIGUOUS,\n messages.TestStepResultStatus.FAILED,\n messages.TestStepResultStatus.UNDEFINED,\n ]\n if (options.strict) {\n failureStatuses.push(messages.TestStepResultStatus.PENDING)\n }\n return failureStatuses.includes(status)\n}\n"]}
|
package/lib/runtime/index.d.ts
CHANGED
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import * as messages from '@cucumber/messages';
|
|
4
|
-
import { IdGenerator } from '@cucumber/messages';
|
|
5
|
-
import { JsonObject } from 'type-fest';
|
|
6
|
-
import { EventDataCollector } from '../formatter/helpers';
|
|
7
|
-
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
8
|
-
export interface IRuntime {
|
|
9
|
-
start: () => Promise<boolean>;
|
|
10
|
-
}
|
|
11
|
-
export interface INewRuntimeOptions {
|
|
12
|
-
eventBroadcaster: EventEmitter;
|
|
13
|
-
eventDataCollector: EventDataCollector;
|
|
14
|
-
newId: IdGenerator.NewId;
|
|
15
|
-
options: IRuntimeOptions;
|
|
16
|
-
pickleIds: string[];
|
|
17
|
-
supportCodeLibrary: SupportCodeLibrary;
|
|
18
|
-
}
|
|
19
|
-
export interface IRuntimeOptions {
|
|
20
|
-
dryRun: boolean;
|
|
21
|
-
failFast: boolean;
|
|
22
|
-
filterStacktraces: boolean;
|
|
23
|
-
retry: number;
|
|
24
|
-
retryTagFilter: string;
|
|
25
|
-
strict: boolean;
|
|
26
|
-
worldParameters: JsonObject;
|
|
27
|
-
}
|
|
28
|
-
export default class Runtime implements IRuntime {
|
|
29
|
-
private readonly eventBroadcaster;
|
|
30
|
-
private readonly eventDataCollector;
|
|
31
|
-
private readonly stopwatch;
|
|
32
|
-
private readonly newId;
|
|
33
|
-
private readonly options;
|
|
34
|
-
private readonly pickleIds;
|
|
35
|
-
private readonly supportCodeLibrary;
|
|
36
|
-
private success;
|
|
37
|
-
private readonly runTestRunHooks;
|
|
38
|
-
constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }: INewRuntimeOptions);
|
|
39
|
-
runTestCase(pickleId: string, testCase: messages.TestCase): Promise<void>;
|
|
40
|
-
start(): Promise<boolean>;
|
|
41
|
-
}
|
|
1
|
+
export * from './make_runtime';
|
|
2
|
+
export { Runtime, RuntimeOptions } from './types';
|
package/lib/runtime/index.js
CHANGED
|
@@ -1,85 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const helpers_1 = require("./helpers");
|
|
8
|
-
const run_test_run_hooks_1 = require("./run_test_run_hooks");
|
|
9
|
-
const stopwatch_1 = require("./stopwatch");
|
|
10
|
-
const test_case_runner_1 = __importDefault(require("./test_case_runner"));
|
|
11
|
-
class Runtime {
|
|
12
|
-
eventBroadcaster;
|
|
13
|
-
eventDataCollector;
|
|
14
|
-
stopwatch;
|
|
15
|
-
newId;
|
|
16
|
-
options;
|
|
17
|
-
pickleIds;
|
|
18
|
-
supportCodeLibrary;
|
|
19
|
-
success;
|
|
20
|
-
runTestRunHooks;
|
|
21
|
-
constructor({ eventBroadcaster, eventDataCollector, newId, options, pickleIds, supportCodeLibrary, }) {
|
|
22
|
-
this.eventBroadcaster = eventBroadcaster;
|
|
23
|
-
this.eventDataCollector = eventDataCollector;
|
|
24
|
-
this.stopwatch = (0, stopwatch_1.create)();
|
|
25
|
-
this.newId = newId;
|
|
26
|
-
this.options = options;
|
|
27
|
-
this.pickleIds = pickleIds;
|
|
28
|
-
this.supportCodeLibrary = supportCodeLibrary;
|
|
29
|
-
this.success = true;
|
|
30
|
-
this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(this.options.dryRun, this.supportCodeLibrary.defaultTimeout, this.options.worldParameters, (name, location) => `${name} hook errored, process exiting: ${location}`);
|
|
31
|
-
}
|
|
32
|
-
async runTestCase(pickleId, testCase) {
|
|
33
|
-
const pickle = this.eventDataCollector.getPickle(pickleId);
|
|
34
|
-
const retries = (0, helpers_1.retriesForPickle)(pickle, this.options);
|
|
35
|
-
const skip = this.options.dryRun || (this.options.failFast && !this.success);
|
|
36
|
-
const testCaseRunner = new test_case_runner_1.default({
|
|
37
|
-
eventBroadcaster: this.eventBroadcaster,
|
|
38
|
-
stopwatch: this.stopwatch,
|
|
39
|
-
gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),
|
|
40
|
-
newId: this.newId,
|
|
41
|
-
pickle,
|
|
42
|
-
testCase,
|
|
43
|
-
retries,
|
|
44
|
-
skip,
|
|
45
|
-
filterStackTraces: this.options.filterStacktraces,
|
|
46
|
-
supportCodeLibrary: this.supportCodeLibrary,
|
|
47
|
-
worldParameters: this.options.worldParameters,
|
|
48
|
-
});
|
|
49
|
-
const status = await testCaseRunner.run();
|
|
50
|
-
if ((0, helpers_1.shouldCauseFailure)(status, this.options)) {
|
|
51
|
-
this.success = false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async start() {
|
|
55
|
-
const testRunStarted = {
|
|
56
|
-
testRunStarted: {
|
|
57
|
-
timestamp: this.stopwatch.timestamp(),
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
this.eventBroadcaster.emit('envelope', testRunStarted);
|
|
61
|
-
this.stopwatch.start();
|
|
62
|
-
await this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');
|
|
63
|
-
const assembledTestCases = await (0, assemble_test_cases_1.assembleTestCases)({
|
|
64
|
-
eventBroadcaster: this.eventBroadcaster,
|
|
65
|
-
newId: this.newId,
|
|
66
|
-
pickles: this.pickleIds.map((pickleId) => this.eventDataCollector.getPickle(pickleId)),
|
|
67
|
-
supportCodeLibrary: this.supportCodeLibrary,
|
|
68
|
-
});
|
|
69
|
-
for (const pickleId of this.pickleIds) {
|
|
70
|
-
await this.runTestCase(pickleId, assembledTestCases[pickleId]);
|
|
71
|
-
}
|
|
72
|
-
await this.runTestRunHooks(this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(), 'an AfterAll');
|
|
73
|
-
this.stopwatch.stop();
|
|
74
|
-
const testRunFinished = {
|
|
75
|
-
testRunFinished: {
|
|
76
|
-
timestamp: this.stopwatch.timestamp(),
|
|
77
|
-
success: this.success,
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
this.eventBroadcaster.emit('envelope', testRunFinished);
|
|
81
|
-
return this.success;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.default = Runtime;
|
|
17
|
+
__exportStar(require("./make_runtime"), exports);
|
|
85
18
|
//# sourceMappingURL=index.js.map
|
package/lib/runtime/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B","sourcesContent":["export * from './make_runtime'\nexport { Runtime, RuntimeOptions } from './types'\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import { IdGenerator } from '@cucumber/messages';
|
|
4
|
+
import { IRunEnvironment, IRunOptionsRuntime } from '../api';
|
|
5
|
+
import { ILogger } from '../logger';
|
|
6
|
+
import { SourcedPickle } from '../assemble';
|
|
7
|
+
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
8
|
+
import { Runtime } from './types';
|
|
9
|
+
export declare function makeRuntime({ environment, logger, eventBroadcaster, sourcedPickles, newId, supportCodeLibrary, options, }: {
|
|
10
|
+
environment: IRunEnvironment;
|
|
11
|
+
logger: ILogger;
|
|
12
|
+
eventBroadcaster: EventEmitter;
|
|
13
|
+
newId: IdGenerator.NewId;
|
|
14
|
+
sourcedPickles: ReadonlyArray<SourcedPickle>;
|
|
15
|
+
supportCodeLibrary: SupportCodeLibrary;
|
|
16
|
+
options: IRunOptionsRuntime;
|
|
17
|
+
}): Promise<Runtime>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeRuntime = void 0;
|
|
4
|
+
const adapter_1 = require("./parallel/adapter");
|
|
5
|
+
const adapter_2 = require("./serial/adapter");
|
|
6
|
+
const coordinator_1 = require("./coordinator");
|
|
7
|
+
async function makeRuntime({ environment, logger, eventBroadcaster, sourcedPickles, newId, supportCodeLibrary, options, }) {
|
|
8
|
+
const adapter = options.parallel > 0
|
|
9
|
+
? new adapter_1.ChildProcessAdapter(environment, logger, eventBroadcaster, options, supportCodeLibrary)
|
|
10
|
+
: new adapter_2.InProcessAdapter(eventBroadcaster, newId, options, supportCodeLibrary);
|
|
11
|
+
return new coordinator_1.Coordinator(eventBroadcaster, newId, sourcedPickles, supportCodeLibrary, adapter);
|
|
12
|
+
}
|
|
13
|
+
exports.makeRuntime = makeRuntime;
|
|
14
|
+
//# sourceMappingURL=make_runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make_runtime.js","sourceRoot":"","sources":["../../src/runtime/make_runtime.ts"],"names":[],"mappings":";;;AAOA,gDAAwD;AACxD,8CAAmD;AACnD,+CAA2C;AAEpC,KAAK,UAAU,WAAW,CAAC,EAChC,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,cAAc,EACd,KAAK,EACL,kBAAkB,EAClB,OAAO,GASR;IACC,MAAM,OAAO,GACX,OAAO,CAAC,QAAQ,GAAG,CAAC;QAClB,CAAC,CAAC,IAAI,6BAAmB,CACrB,WAAW,EACX,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,kBAAkB,CACnB;QACH,CAAC,CAAC,IAAI,0BAAgB,CAClB,gBAAgB,EAChB,KAAK,EACL,OAAO,EACP,kBAAkB,CACnB,CAAA;IACP,OAAO,IAAI,yBAAW,CACpB,gBAAgB,EAChB,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,OAAO,CACR,CAAA;AACH,CAAC;AAvCD,kCAuCC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { IdGenerator } from '@cucumber/messages'\nimport { IRunEnvironment, IRunOptionsRuntime } from '../api'\nimport { ILogger } from '../logger'\nimport { SourcedPickle } from '../assemble'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { Runtime, RuntimeAdapter } from './types'\nimport { ChildProcessAdapter } from './parallel/adapter'\nimport { InProcessAdapter } from './serial/adapter'\nimport { Coordinator } from './coordinator'\n\nexport async function makeRuntime({\n environment,\n logger,\n eventBroadcaster,\n sourcedPickles,\n newId,\n supportCodeLibrary,\n options,\n}: {\n environment: IRunEnvironment\n logger: ILogger\n eventBroadcaster: EventEmitter\n newId: IdGenerator.NewId\n sourcedPickles: ReadonlyArray<SourcedPickle>\n supportCodeLibrary: SupportCodeLibrary\n options: IRunOptionsRuntime\n}): Promise<Runtime> {\n const adapter: RuntimeAdapter =\n options.parallel > 0\n ? new ChildProcessAdapter(\n environment,\n logger,\n eventBroadcaster,\n options,\n supportCodeLibrary\n )\n : new InProcessAdapter(\n eventBroadcaster,\n newId,\n options,\n supportCodeLibrary\n )\n return new Coordinator(\n eventBroadcaster,\n newId,\n sourcedPickles,\n supportCodeLibrary,\n adapter\n )\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { ChildProcess } from 'node:child_process';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import { SupportCodeLibrary } from '../../support_code_library_builder/types';
|
|
6
|
+
import { AssembledTestCase } from '../../assemble';
|
|
7
|
+
import { ILogger } from '../../logger';
|
|
8
|
+
import { RuntimeAdapter } from '../types';
|
|
9
|
+
import { IRunEnvironment, IRunOptionsRuntime } from '../../api';
|
|
10
|
+
import { WorkerToCoordinatorEvent } from './types';
|
|
11
|
+
declare const enum WorkerState {
|
|
12
|
+
'idle' = 0,
|
|
13
|
+
'closed' = 1,
|
|
14
|
+
'running' = 2,
|
|
15
|
+
'new' = 3
|
|
16
|
+
}
|
|
17
|
+
interface ManagedWorker {
|
|
18
|
+
state: WorkerState;
|
|
19
|
+
process: ChildProcess;
|
|
20
|
+
id: string;
|
|
21
|
+
}
|
|
22
|
+
interface WorkPlacement {
|
|
23
|
+
index: number;
|
|
24
|
+
item: AssembledTestCase;
|
|
25
|
+
}
|
|
26
|
+
export declare class ChildProcessAdapter implements RuntimeAdapter {
|
|
27
|
+
private readonly environment;
|
|
28
|
+
private readonly logger;
|
|
29
|
+
private readonly eventBroadcaster;
|
|
30
|
+
private readonly options;
|
|
31
|
+
private readonly supportCodeLibrary;
|
|
32
|
+
private idleInterventions;
|
|
33
|
+
private failing;
|
|
34
|
+
private onFinish;
|
|
35
|
+
private todo;
|
|
36
|
+
private readonly inProgress;
|
|
37
|
+
private readonly workers;
|
|
38
|
+
constructor(environment: IRunEnvironment, logger: ILogger, eventBroadcaster: EventEmitter, options: IRunOptionsRuntime, supportCodeLibrary: SupportCodeLibrary);
|
|
39
|
+
parseWorkerMessage(worker: ManagedWorker, message: WorkerToCoordinatorEvent): void;
|
|
40
|
+
awakenWorkers(triggeringWorker: ManagedWorker): void;
|
|
41
|
+
startWorker(id: string, total: number): void;
|
|
42
|
+
onWorkerProcessClose(exitCode: number): void;
|
|
43
|
+
run(assembledTestCases: ReadonlyArray<AssembledTestCase>): Promise<boolean>;
|
|
44
|
+
nextWorkPlacement(): WorkPlacement;
|
|
45
|
+
placementAt(index: number): WorkPlacement;
|
|
46
|
+
giveWork(worker: ManagedWorker, force?: boolean): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|