@cucumber/cucumber 10.0.1 → 10.1.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/gherkin.d.ts +5 -13
- package/lib/api/gherkin.js +6 -26
- package/lib/api/gherkin.js.map +1 -1
- package/lib/api/load_sources.js +16 -9
- package/lib/api/load_sources.js.map +1 -1
- package/lib/api/load_support.js +11 -4
- package/lib/api/load_support.js.map +1 -1
- package/lib/api/plugins.d.ts +4 -2
- package/lib/api/plugins.js +19 -8
- package/lib/api/plugins.js.map +1 -1
- package/lib/api/run_cucumber.js +19 -13
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/cli/run.js +1 -2
- package/lib/cli/run.js.map +1 -1
- package/lib/configuration/types.d.ts +2 -1
- package/lib/configuration/types.js.map +1 -1
- package/lib/filter/filter_plugin.d.ts +3 -0
- package/lib/filter/filter_plugin.js +32 -0
- package/lib/filter/filter_plugin.js.map +1 -0
- package/lib/filter/index.d.ts +3 -0
- package/lib/filter/index.js +20 -0
- package/lib/filter/index.js.map +1 -0
- package/lib/filter/types.d.ts +6 -0
- package/lib/filter/types.js +3 -0
- package/lib/filter/types.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/paths/index.d.ts +2 -0
- package/lib/paths/index.js +19 -0
- package/lib/paths/index.js.map +1 -0
- package/lib/paths/paths.d.ts +4 -0
- package/lib/{api → paths}/paths.js +8 -8
- package/lib/paths/paths.js.map +1 -0
- package/lib/paths/types.d.ts +6 -0
- package/lib/paths/types.js +3 -0
- package/lib/paths/types.js.map +1 -0
- package/lib/plugin/events.d.ts +2 -0
- package/lib/plugin/events.js +9 -0
- package/lib/plugin/events.js.map +1 -0
- package/lib/plugin/plugin_manager.d.ts +5 -6
- package/lib/plugin/plugin_manager.js +26 -16
- package/lib/plugin/plugin_manager.js.map +1 -1
- package/lib/plugin/types.d.ts +34 -10
- package/lib/plugin/types.js.map +1 -1
- package/lib/publish/publish_plugin.d.ts +3 -2
- package/lib/publish/publish_plugin.js +27 -25
- package/lib/publish/publish_plugin.js.map +1 -1
- package/lib/runtime/index.d.ts +2 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/run_worker.js +1 -2
- package/lib/runtime/parallel/run_worker.js.map +1 -1
- package/lib/runtime/parallel/worker.js +1 -1
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/run_test_run_hooks.d.ts +2 -1
- package/lib/runtime/run_test_run_hooks.js +3 -4
- package/lib/runtime/run_test_run_hooks.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +2 -1
- package/lib/runtime/test_case_runner.js +1 -1
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +6 -2
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/try_require.js +1 -3
- package/lib/try_require.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/package.json +13 -14
- package/lib/api/paths.d.ts +0 -8
- package/lib/api/paths.js.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
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);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./paths"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/paths/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,0CAAuB","sourcesContent":["export * from './paths'\nexport * from './types'\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ILogger } from '../logger';
|
|
2
|
+
import { ISourcesCoordinates, ISupportCodeCoordinates } from '../api';
|
|
3
|
+
import { IResolvedPaths } from './types';
|
|
4
|
+
export declare function resolvePaths(logger: ILogger, cwd: string, sources: Pick<ISourcesCoordinates, 'paths'>, support?: ISupportCodeCoordinates): Promise<IResolvedPaths>;
|
|
@@ -12,15 +12,15 @@ async function resolvePaths(logger, cwd, sources, support = {
|
|
|
12
12
|
requirePaths: [],
|
|
13
13
|
importPaths: [],
|
|
14
14
|
}) {
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
logger.debug('Found
|
|
18
|
-
const { requirePaths, importPaths } = await deriveSupportPaths(cwd,
|
|
15
|
+
const unexpandedSourcePaths = await getUnexpandedSourcePaths(cwd, sources.paths);
|
|
16
|
+
const sourcePaths = await expandSourcePaths(cwd, unexpandedSourcePaths);
|
|
17
|
+
logger.debug('Found source files based on configuration:', sourcePaths);
|
|
18
|
+
const { requirePaths, importPaths } = await deriveSupportPaths(cwd, sourcePaths, support.requirePaths, support.importPaths);
|
|
19
19
|
logger.debug('Found support files to load via `require` based on configuration:', requirePaths);
|
|
20
20
|
logger.debug('Found support files to load via `import` based on configuration:', importPaths);
|
|
21
21
|
return {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
unexpandedSourcePaths: unexpandedSourcePaths,
|
|
23
|
+
sourcePaths: sourcePaths,
|
|
24
24
|
requirePaths,
|
|
25
25
|
importPaths,
|
|
26
26
|
};
|
|
@@ -46,7 +46,7 @@ async function expandPaths(cwd, unexpandedPaths, defaultExtension) {
|
|
|
46
46
|
const normalized = expandedPaths.flat().map((x) => node_path_1.default.normalize(x));
|
|
47
47
|
return [...new Set(normalized)];
|
|
48
48
|
}
|
|
49
|
-
async function
|
|
49
|
+
async function getUnexpandedSourcePaths(cwd, args) {
|
|
50
50
|
if (args.length > 0) {
|
|
51
51
|
const nestedFeaturePaths = await Promise.all(args.map(async (arg) => {
|
|
52
52
|
const filename = node_path_1.default.basename(arg);
|
|
@@ -81,7 +81,7 @@ function getFeatureDirectoryPaths(cwd, featurePaths) {
|
|
|
81
81
|
});
|
|
82
82
|
return [...new Set(featureDirs)];
|
|
83
83
|
}
|
|
84
|
-
async function
|
|
84
|
+
async function expandSourcePaths(cwd, featurePaths) {
|
|
85
85
|
featurePaths = featurePaths.map((p) => p.replace(/(:\d+)*$/g, '')); // Strip line numbers
|
|
86
86
|
return await expandPaths(cwd, featurePaths, '.feature');
|
|
87
87
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/paths/paths.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAC5B,+BAA2B;AAC3B,+CAAsB;AAKf,KAAK,UAAU,YAAY,CAChC,MAAe,EACf,GAAW,EACX,OAA2C,EAC3C,UAAmC;IACjC,cAAc,EAAE,EAAE;IAClB,YAAY,EAAE,EAAE;IAChB,WAAW,EAAE,EAAE;CAChB;IAED,MAAM,qBAAqB,GAAG,MAAM,wBAAwB,CAC1D,GAAG,EACH,OAAO,CAAC,KAAK,CACd,CAAA;IACD,MAAM,WAAW,GAAa,MAAM,iBAAiB,CACnD,GAAG,EACH,qBAAqB,CACtB,CAAA;IACD,MAAM,CAAC,KAAK,CAAC,4CAA4C,EAAE,WAAW,CAAC,CAAA;IACvE,MAAM,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M,YAAY,GAChB,sBAAsB,CAAC,MAAM,GAAG,CAAC;QAC/B,CAAC,CAAC,MAAM,WAAW,CAAC,GAAG,EAAE,sBAAsB,EAAE,KAAK,CAAC;QACvD,CAAC,CAAC,EAAE,CAAA;IACR,MAAM,WAAW,GACf,qBAAqB,CAAC,MAAM,GAAG,CAAC;QAC9B,CAAC,CAAC,MAAM,WAAW,CAAC,GAAG,EAAE,qBAAqB,EAAE,gBAAgB,CAAC;QACjE,CAAC,CAAC,EAAE,CAAA;IACR,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,CAAA;AACtC,CAAC","sourcesContent":["import path from 'node:path'\nimport { glob } from 'glob'\nimport fs from 'mz/fs'\nimport { ILogger } from '../logger'\nimport { ISourcesCoordinates, ISupportCodeCoordinates } from '../api'\nimport { IResolvedPaths } from './types'\n\nexport async function resolvePaths(\n logger: ILogger,\n cwd: string,\n sources: Pick<ISourcesCoordinates, 'paths'>,\n support: ISupportCodeCoordinates = {\n requireModules: [],\n requirePaths: [],\n importPaths: [],\n }\n): Promise<IResolvedPaths> {\n const unexpandedSourcePaths = await getUnexpandedSourcePaths(\n cwd,\n sources.paths\n )\n const sourcePaths: string[] = await expandSourcePaths(\n cwd,\n unexpandedSourcePaths\n )\n logger.debug('Found source files based on configuration:', sourcePaths)\n const { requirePaths, importPaths } = await deriveSupportPaths(\n cwd,\n sourcePaths,\n support.requirePaths,\n support.importPaths\n )\n logger.debug(\n 'Found support files to load via `require` based on configuration:',\n requirePaths\n )\n logger.debug(\n 'Found support files to load via `import` based on configuration:',\n importPaths\n )\n return {\n unexpandedSourcePaths: unexpandedSourcePaths,\n sourcePaths: sourcePaths,\n requirePaths,\n importPaths,\n }\n}\n\nasync function expandPaths(\n cwd: string,\n unexpandedPaths: string[],\n defaultExtension: string\n): Promise<string[]> {\n const expandedPaths = await Promise.all(\n unexpandedPaths.map(async (unexpandedPath) => {\n const matches = await glob(unexpandedPath, {\n absolute: true,\n windowsPathsNoEscape: true,\n cwd,\n })\n const expanded = await Promise.all(\n matches.map(async (match) => {\n if (path.extname(match) === '') {\n return glob(`${match}/**/*${defaultExtension}`, {\n windowsPathsNoEscape: true,\n })\n }\n return [match]\n })\n )\n return expanded.flat().sort()\n })\n )\n const normalized = expandedPaths.flat().map((x) => path.normalize(x))\n return [...new Set(normalized)]\n}\n\nasync function getUnexpandedSourcePaths(\n cwd: string,\n args: string[]\n): Promise<string[]> {\n if (args.length > 0) {\n const nestedFeaturePaths = await Promise.all(\n args.map(async (arg) => {\n const filename = path.basename(arg)\n if (filename[0] === '@') {\n const filePath = path.join(cwd, arg)\n const content = await fs.readFile(filePath, 'utf8')\n return content.split('\\n').map((x) => x.trim())\n }\n return [arg]\n })\n )\n const featurePaths = nestedFeaturePaths.flat()\n if (featurePaths.length > 0) {\n return featurePaths.filter((x) => x !== '')\n }\n }\n return ['features/**/*.{feature,feature.md}']\n}\n\nfunction getFeatureDirectoryPaths(\n cwd: string,\n featurePaths: string[]\n): string[] {\n const featureDirs = featurePaths.map((featurePath) => {\n let featureDir = path.dirname(featurePath)\n let childDir: string\n let parentDir = featureDir\n while (childDir !== parentDir) {\n childDir = parentDir\n parentDir = path.dirname(childDir)\n if (path.basename(parentDir) === 'features') {\n featureDir = parentDir\n break\n }\n }\n return path.relative(cwd, featureDir)\n })\n return [...new Set(featureDirs)]\n}\n\nasync function expandSourcePaths(\n cwd: string,\n featurePaths: string[]\n): Promise<string[]> {\n featurePaths = featurePaths.map((p) => p.replace(/(:\\d+)*$/g, '')) // Strip line numbers\n return await expandPaths(cwd, featurePaths, '.feature')\n}\n\nasync function deriveSupportPaths(\n cwd: string,\n featurePaths: string[],\n unexpandedRequirePaths: string[],\n unexpandedImportPaths: string[]\n): Promise<{\n requirePaths: string[]\n importPaths: string[]\n}> {\n if (\n unexpandedRequirePaths.length === 0 &&\n unexpandedImportPaths.length === 0\n ) {\n const defaultPaths = getFeatureDirectoryPaths(cwd, featurePaths)\n const importPaths = await expandPaths(cwd, defaultPaths, '.@(js|cjs|mjs)')\n return { requirePaths: [], importPaths }\n }\n const requirePaths =\n unexpandedRequirePaths.length > 0\n ? await expandPaths(cwd, unexpandedRequirePaths, '.js')\n : []\n const importPaths =\n unexpandedImportPaths.length > 0\n ? await expandPaths(cwd, unexpandedImportPaths, '.@(js|cjs|mjs)')\n : []\n return { requirePaths, importPaths }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/paths/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface IResolvedPaths {\n unexpandedSourcePaths: string[]\n sourcePaths: string[]\n requirePaths: string[]\n importPaths: string[]\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.coordinatorTransformKeys = exports.coordinatorVoidKeys = void 0;
|
|
4
|
+
exports.coordinatorVoidKeys = ['message', 'paths:resolve'];
|
|
5
|
+
exports.coordinatorTransformKeys = [
|
|
6
|
+
'pickles:filter',
|
|
7
|
+
'pickles:order',
|
|
8
|
+
];
|
|
9
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/plugin/events.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,CAAC,SAAS,EAAE,eAAe,CAAU,CAAA;AAC3D,QAAA,wBAAwB,GAAG;IACtC,gBAAgB;IAChB,eAAe;CACP,CAAA","sourcesContent":["export const coordinatorVoidKeys = ['message', 'paths:resolve'] as const\nexport const coordinatorTransformKeys = [\n 'pickles:filter',\n 'pickles:order',\n] as const\n"]}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { IRunEnvironment
|
|
1
|
+
import { IRunEnvironment } from '../api';
|
|
2
2
|
import { ILogger } from '../logger';
|
|
3
|
-
import {
|
|
3
|
+
import { InternalPlugin, CoordinatorPluginEventValues, CoordinatorPluginEventKey, CoordinatorPluginTransformEventKey, Operation } from './types';
|
|
4
4
|
export declare class PluginManager {
|
|
5
|
-
private pluginFns;
|
|
6
5
|
private handlers;
|
|
7
6
|
private cleanupFns;
|
|
8
|
-
constructor(pluginFns: Plugin[]);
|
|
9
7
|
private register;
|
|
10
|
-
init(
|
|
11
|
-
emit<K extends
|
|
8
|
+
init<OptionsType>(operation: Operation, plugin: InternalPlugin<OptionsType>, options: OptionsType, logger: ILogger, environment: Required<IRunEnvironment>): Promise<void>;
|
|
9
|
+
emit<K extends CoordinatorPluginEventKey>(event: K, value: CoordinatorPluginEventValues[K]): void;
|
|
10
|
+
transform<K extends CoordinatorPluginTransformEventKey>(event: K, value: CoordinatorPluginEventValues[K]): Promise<CoordinatorPluginEventValues[K]>;
|
|
12
11
|
cleanup(): Promise<void>;
|
|
13
12
|
}
|
|
@@ -2,31 +2,41 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PluginManager = void 0;
|
|
4
4
|
class PluginManager {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
handlers = {
|
|
6
|
+
message: [],
|
|
7
|
+
'paths:resolve': [],
|
|
8
|
+
'pickles:filter': [],
|
|
9
|
+
'pickles:order': [],
|
|
10
|
+
};
|
|
7
11
|
cleanupFns = [];
|
|
8
|
-
constructor(pluginFns) {
|
|
9
|
-
this.pluginFns = pluginFns;
|
|
10
|
-
}
|
|
11
12
|
async register(event, handler) {
|
|
12
13
|
this.handlers[event].push(handler);
|
|
13
14
|
}
|
|
14
|
-
async init(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
15
|
+
async init(operation, plugin, options, logger, environment) {
|
|
16
|
+
const cleanupFn = await plugin.coordinator({
|
|
17
|
+
operation,
|
|
18
|
+
on: this.register.bind(this),
|
|
19
|
+
options,
|
|
20
|
+
logger,
|
|
21
|
+
environment,
|
|
22
|
+
});
|
|
23
|
+
if (typeof cleanupFn === 'function') {
|
|
24
|
+
this.cleanupFns.push(cleanupFn);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
emit(event, value) {
|
|
28
28
|
this.handlers[event].forEach((handler) => handler(value));
|
|
29
29
|
}
|
|
30
|
+
async transform(event, value) {
|
|
31
|
+
let transformed = value;
|
|
32
|
+
for (const handler of this.handlers[event]) {
|
|
33
|
+
const returned = await handler(transformed);
|
|
34
|
+
if (typeof returned !== 'undefined') {
|
|
35
|
+
transformed = returned;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return transformed;
|
|
39
|
+
}
|
|
30
40
|
async cleanup() {
|
|
31
41
|
for (const cleanupFn of this.cleanupFns) {
|
|
32
42
|
await cleanupFn();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin_manager.js","sourceRoot":"","sources":["../../src/plugin/plugin_manager.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plugin_manager.js","sourceRoot":"","sources":["../../src/plugin/plugin_manager.ts"],"names":[],"mappings":";;;AAgBA,MAAa,aAAa;IAChB,QAAQ,GAAoB;QAClC,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,EAAE;QACnB,gBAAgB,EAAE,EAAE;QACpB,eAAe,EAAE,EAAE;KACpB,CAAA;IACO,UAAU,GAAoB,EAAE,CAAA;IAEhC,KAAK,CAAC,QAAQ,CACpB,KAAQ,EACR,OAAyC;QAEzC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,IAAI,CACR,SAAoB,EACpB,MAAmC,EACnC,OAAoB,EACpB,MAAe,EACf,WAAsC;QAEtC,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;YACzC,SAAS;YACT,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5B,OAAO;YACP,MAAM;YACN,WAAW;SACZ,CAAC,CAAA;QACF,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;YACnC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;SAChC;IACH,CAAC;IAED,IAAI,CACF,KAAQ,EACR,KAAsC;QAEtC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,SAAS,CACb,KAAQ,EACR,KAAsC;QAEtC,IAAI,WAAW,GAAG,KAAK,CAAA;QACvB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC1C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,CAAA;YAC3C,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;gBACnC,WAAW,GAAG,QAAQ,CAAA;aACvB;SACF;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;YACvC,MAAM,SAAS,EAAE,CAAA;SAClB;IACH,CAAC;CACF;AA7DD,sCA6DC","sourcesContent":["import { IRunEnvironment } from '../api'\nimport { ILogger } from '../logger'\nimport {\n CoordinatorPluginEventHandler,\n InternalPlugin,\n PluginCleanup,\n CoordinatorPluginEventValues,\n CoordinatorPluginEventKey,\n CoordinatorPluginTransformEventKey,\n Operation,\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 init<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
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
import { Envelope } from '@cucumber/messages';
|
|
2
|
-
import {
|
|
2
|
+
import { ArrayValues, Promisable } from 'type-fest';
|
|
3
|
+
import { IRunEnvironment } from '../api';
|
|
3
4
|
import { ILogger } from '../logger';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export
|
|
8
|
-
|
|
5
|
+
import { IFilterablePickle } from '../filter';
|
|
6
|
+
import { IResolvedPaths } from '../paths';
|
|
7
|
+
import { coordinatorTransformKeys, coordinatorVoidKeys } from './events';
|
|
8
|
+
export type Operation = 'loadSources' | 'loadSupport' | 'runCucumber';
|
|
9
|
+
export type CoordinatorPluginVoidEventKey = ArrayValues<typeof coordinatorVoidKeys>;
|
|
10
|
+
export type CoordinatorPluginTransformEventKey = ArrayValues<typeof coordinatorTransformKeys>;
|
|
11
|
+
export type CoordinatorPluginEventKey = CoordinatorPluginVoidEventKey | CoordinatorPluginTransformEventKey;
|
|
12
|
+
export type CoordinatorPluginEventValues = {
|
|
13
|
+
message: Readonly<Envelope>;
|
|
14
|
+
'paths:resolve': Readonly<IResolvedPaths>;
|
|
15
|
+
'pickles:filter': Readonly<Array<IFilterablePickle>>;
|
|
16
|
+
'pickles:order': Readonly<Array<IFilterablePickle>>;
|
|
17
|
+
};
|
|
18
|
+
export type CoordinatorPluginEventHandler<K extends CoordinatorPluginEventKey> = (value: CoordinatorPluginEventValues[K]) => K extends CoordinatorPluginTransformEventKey ? Promisable<CoordinatorPluginEventValues[K]> : void;
|
|
19
|
+
export interface CoordinatorPluginContext<OptionsType> {
|
|
20
|
+
operation: Operation;
|
|
21
|
+
on: <EventKey extends CoordinatorPluginEventKey>(event: EventKey, handler: CoordinatorPluginEventHandler<EventKey>) => void;
|
|
22
|
+
options: OptionsType;
|
|
9
23
|
logger: ILogger;
|
|
10
|
-
|
|
11
|
-
|
|
24
|
+
environment: Required<IRunEnvironment>;
|
|
25
|
+
}
|
|
26
|
+
export type CoordinatorPluginFunction<OptionsType> = (context: CoordinatorPluginContext<OptionsType>) => Promisable<PluginCleanup | void>;
|
|
27
|
+
export type PluginCleanup = () => Promisable<void>;
|
|
28
|
+
/**
|
|
29
|
+
* A plugin to implement Cucumber built-in functionality.
|
|
30
|
+
*
|
|
31
|
+
* Uses the same events and mechanisms as user-authored plugins, but is free to require configuration and context from
|
|
32
|
+
* inside of Cucumber as its `options`, whereas user-authored plugins will be limited to `pluginOptions` from the
|
|
33
|
+
* project configuration.
|
|
34
|
+
*/
|
|
35
|
+
export interface InternalPlugin<OptionsType = any> {
|
|
36
|
+
type: 'plugin';
|
|
37
|
+
coordinator: CoordinatorPluginFunction<OptionsType>;
|
|
12
38
|
}
|
|
13
|
-
export type PluginCleanup = () => any | void | Promise<any | void>;
|
|
14
|
-
export type Plugin = (context: PluginContext) => Promise<PluginCleanup | void>;
|
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 {
|
|
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"]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { InternalPlugin } from '../plugin';
|
|
2
|
+
import { IPublishConfig } from '../formatter';
|
|
3
|
+
export declare const publishPlugin: InternalPlugin<IPublishConfig | false>;
|
|
@@ -10,32 +10,34 @@ const has_ansi_1 = __importDefault(require("has-ansi"));
|
|
|
10
10
|
const strip_ansi_1 = __importDefault(require("strip-ansi"));
|
|
11
11
|
const http_stream_1 = __importDefault(require("./http_stream"));
|
|
12
12
|
const DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
headers
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
writeCallback
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
exports.publishPlugin = {
|
|
14
|
+
type: 'plugin',
|
|
15
|
+
coordinator: async ({ on, logger, options, environment }) => {
|
|
16
|
+
if (!options) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
const { url = DEFAULT_CUCUMBER_PUBLISH_URL, token } = options;
|
|
20
|
+
const headers = {};
|
|
21
|
+
if (token !== undefined) {
|
|
22
|
+
headers.Authorization = `Bearer ${token}`;
|
|
23
|
+
}
|
|
24
|
+
const stream = new http_stream_1.default(url, 'GET', headers);
|
|
25
|
+
const readerStream = new node_stream_1.Writable({
|
|
26
|
+
objectMode: true,
|
|
27
|
+
write: function (responseBody, encoding, writeCallback) {
|
|
28
|
+
environment.stderr.write(sanitisePublishOutput(responseBody, environment.stderr) + '\n');
|
|
29
|
+
writeCallback();
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
stream.pipe(readerStream);
|
|
33
|
+
stream.on('error', (error) => logger.error(error.message));
|
|
34
|
+
on('message', (value) => stream.write(JSON.stringify(value) + '\n'));
|
|
35
|
+
return () => new Promise((resolve) => {
|
|
36
|
+
stream.on('finish', () => resolve());
|
|
37
|
+
stream.end();
|
|
38
|
+
});
|
|
39
|
+
},
|
|
37
40
|
};
|
|
38
|
-
exports.publishPlugin = publishPlugin;
|
|
39
41
|
/*
|
|
40
42
|
This is because the Cucumber Reports service returns a pre-formatted console message
|
|
41
43
|
including ANSI escapes, so if our stderr stream doesn't support those we need to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish_plugin.js","sourceRoot":"","sources":["../../src/publish/publish_plugin.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAsC;AACtC,mDAA8C;AAC9C,wDAA8B;AAC9B,4DAAkC;
|
|
1
|
+
{"version":3,"file":"publish_plugin.js","sourceRoot":"","sources":["../../src/publish/publish_plugin.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAsC;AACtC,mDAA8C;AAC9C,wDAA8B;AAC9B,4DAAkC;AAGlC,gEAAsC;AAEtC,MAAM,4BAA4B,GAAG,0CAA0C,CAAA;AAElE,QAAA,aAAa,GAA2C;IACnE,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE;QAC1D,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,SAAS,CAAA;SACjB;QACD,MAAM,EAAE,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AAa,EAAC,MAAM,CAAC,IAAI,IAAA,kBAAO,EAAC,GAAG,CAAC,EAAE;QAC1C,OAAO,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAA;KACtB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import { Writable } from 'node:stream'\nimport { supportsColor } from 'supports-color'\nimport hasAnsi from 'has-ansi'\nimport stripAnsi from 'strip-ansi'\nimport { InternalPlugin } from '../plugin'\nimport { IPublishConfig } from '../formatter'\nimport HttpStream from './http_stream'\n\nconst DEFAULT_CUCUMBER_PUBLISH_URL = 'https://messages.cucumber.io/api/reports'\n\nexport const publishPlugin: InternalPlugin<IPublishConfig | false> = {\n type: 'plugin',\n coordinator: async ({ on, logger, options, environment }) => {\n if (!options) {\n return undefined\n }\n const { url = DEFAULT_CUCUMBER_PUBLISH_URL, token } = options\n const headers: { [key: string]: string } = {}\n if (token !== undefined) {\n headers.Authorization = `Bearer ${token}`\n }\n const stream = new HttpStream(url, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n environment.stderr.write(\n sanitisePublishOutput(responseBody, environment.stderr) + '\\n'\n )\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n stream.on('error', (error: Error) => logger.error(error.message))\n on('message', (value) => stream.write(JSON.stringify(value) + '\\n'))\n return () =>\n new Promise<void>((resolve) => {\n stream.on('finish', () => resolve())\n stream.end()\n })\n },\n}\n\n/*\nThis is because the Cucumber Reports service returns a pre-formatted console message\nincluding ANSI escapes, so if our stderr stream doesn't support those we need to\nstrip them back out. Ideally we should get structured data from the service and\ncompose the console message on this end.\n */\nfunction sanitisePublishOutput(raw: string, stderr: Writable) {\n if (!supportsColor(stderr) && hasAnsi(raw)) {\n return stripAnsi(raw)\n }\n return raw\n}\n"]}
|
package/lib/runtime/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import * as messages from '@cucumber/messages';
|
|
4
4
|
import { IdGenerator } from '@cucumber/messages';
|
|
5
|
+
import { JsonObject } from 'type-fest';
|
|
5
6
|
import { EventDataCollector } from '../formatter/helpers';
|
|
6
7
|
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
7
8
|
export interface IRuntime {
|
|
@@ -22,7 +23,7 @@ export interface IRuntimeOptions {
|
|
|
22
23
|
retry: number;
|
|
23
24
|
retryTagFilter: string;
|
|
24
25
|
strict: boolean;
|
|
25
|
-
worldParameters:
|
|
26
|
+
worldParameters: JsonObject;
|
|
26
27
|
}
|
|
27
28
|
export default class Runtime implements IRuntime {
|
|
28
29
|
private readonly eventBroadcaster;
|
package/lib/runtime/index.js
CHANGED
|
@@ -27,7 +27,7 @@ class Runtime {
|
|
|
27
27
|
this.pickleIds = pickleIds;
|
|
28
28
|
this.supportCodeLibrary = supportCodeLibrary;
|
|
29
29
|
this.success = true;
|
|
30
|
-
this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(this.options.dryRun, this.supportCodeLibrary.defaultTimeout, (name, location) => `${name} hook errored, process exiting: ${location}`);
|
|
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
31
|
}
|
|
32
32
|
async runTestCase(pickleId, testCase) {
|
|
33
33
|
const pickle = this.eventDataCollector.getPickle(pickleId);
|
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":";;;;;AAMA,+DAAyD;AACzD,uCAAgE;AAChE,6DAA4E;AAC5E,2CAAgD;AAChD,0EAA+C;AAyB/C,MAAqB,OAAO;IACT,gB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CAAC,kBAAkB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAC5C;YACD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC5C,CAAC,CAAA;QACF,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE;YACrC,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAA;SAC/D;QACD,MAAM,IAAI,CAAC,eAAe,CACxB,IAAI,CAAC,kBAAkB,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EACtE,aAAa,CACd,CAAA;QACD,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAA;QACrB,MAAM,eAAe,GAAsB;YACzC,eAAe,EAAE;gBACf,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;gBACrC,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB;SACF,CAAA;QACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAA;QACvD,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AAlGD,0BAkGC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { JsonObject } from 'type-fest'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { assembleTestCases } from './assemble_test_cases'\nimport { retriesForPickle, shouldCauseFailure } from './helpers'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from './run_test_run_hooks'\nimport { IStopwatch, create } from './stopwatch'\nimport TestCaseRunner from './test_case_runner'\n\nexport interface IRuntime {\n start: () => Promise<boolean>\n}\n\nexport interface INewRuntimeOptions {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n newId: IdGenerator.NewId\n options: IRuntimeOptions\n pickleIds: string[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IRuntimeOptions {\n dryRun: boolean\n failFast: boolean\n filterStacktraces: boolean\n retry: number\n retryTagFilter: string\n strict: boolean\n worldParameters: JsonObject\n}\n\nexport default class Runtime implements IRuntime {\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: IStopwatch\n private readonly newId: IdGenerator.NewId\n private readonly options: IRuntimeOptions\n private readonly pickleIds: string[]\n private readonly supportCodeLibrary: ISupportCodeLibrary\n private success: boolean\n private runTestRunHooks: RunsTestRunHooks\n\n constructor({\n eventBroadcaster,\n eventDataCollector,\n newId,\n options,\n pickleIds,\n supportCodeLibrary,\n }: INewRuntimeOptions) {\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = create()\n this.newId = newId\n this.options = options\n this.pickleIds = pickleIds\n this.supportCodeLibrary = supportCodeLibrary\n this.success = true\n this.runTestRunHooks = makeRunTestRunHooks(\n this.options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n this.options.worldParameters,\n (name, location) => `${name} hook errored, process exiting: ${location}`\n )\n }\n\n async runTestCase(\n pickleId: string,\n testCase: messages.TestCase\n ): Promise<void> {\n const pickle = this.eventDataCollector.getPickle(pickleId)\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch: this.stopwatch,\n gherkinDocument: this.eventDataCollector.getGherkinDocument(pickle.uri),\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n filterStackTraces: this.options.filterStacktraces,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.options.worldParameters,\n })\n const status = await testCaseRunner.run()\n if (shouldCauseFailure(status, this.options)) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n const testRunStarted: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', testRunStarted)\n this.stopwatch.start()\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n const assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n for (const pickleId of this.pickleIds) {\n await this.runTestCase(pickleId, assembledTestCases[pickleId])\n }\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse(),\n 'an AfterAll'\n )\n this.stopwatch.stop()\n const testRunFinished: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success: this.success,\n },\n }\n this.eventBroadcaster.emit('envelope', testRunFinished)\n return this.success\n }\n}\n"]}
|
|
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const verror_1 = __importDefault(require("verror"));
|
|
7
6
|
const value_checker_1 = require("../../value_checker");
|
|
8
7
|
const worker_1 = __importDefault(require("./worker"));
|
|
9
8
|
function run() {
|
|
10
9
|
const exit = (exitCode, error, message) => {
|
|
11
10
|
if ((0, value_checker_1.doesHaveValue)(error)) {
|
|
12
|
-
console.error(
|
|
11
|
+
console.error(new Error(message, { cause: error })); // eslint-disable-line no-console
|
|
13
12
|
}
|
|
14
13
|
process.exit(exitCode);
|
|
15
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run_worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/run_worker.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"run_worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/run_worker.ts"],"names":[],"mappings":";;;;;AAAA,uDAAmD;AACnD,sDAA6B;AAE7B,SAAS,GAAG;IACV,MAAM,IAAI,GAAG,CAAC,QAAgB,EAAE,KAAa,EAAE,OAAgB,EAAQ,EAAE;QACvE,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,EAAE;YACxB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA,CAAC,iCAAiC;SACtF;QACD,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACxB,CAAC,CAAA;IACD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC;QACxB,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;QAClC,WAAW,EAAE,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QACpD,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI;KACL,CAAC,CAAA;IACF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,CAAM,EAAQ,EAAE;QACrC,MAAM;aACH,cAAc,CAAC,CAAC,CAAC;aACjB,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE,CACtB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,2CAA2C,CAAC,CAC5D,CAAA;IACL,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,GAAG,EAAE,CAAA","sourcesContent":["import { doesHaveValue } from '../../value_checker'\nimport Worker from './worker'\n\nfunction run(): void {\n const exit = (exitCode: number, error?: Error, message?: string): void => {\n if (doesHaveValue(error)) {\n console.error(new Error(message, { cause: error })) // eslint-disable-line no-console\n }\n process.exit(exitCode)\n }\n const worker = new Worker({\n id: process.env.CUCUMBER_WORKER_ID,\n sendMessage: (message: any) => process.send(message),\n cwd: process.cwd(),\n exit,\n })\n process.on('message', (m: any): void => {\n worker\n .receiveMessage(m)\n .catch((error: Error) =>\n exit(1, error, 'Unexpected error on worker.receiveMessage')\n )\n })\n}\n\nrun()\n"]}
|
|
@@ -53,7 +53,7 @@ class Worker {
|
|
|
53
53
|
this.supportCodeLibrary = support_code_library_builder_1.default.finalize(supportCodeIds);
|
|
54
54
|
this.worldParameters = options.worldParameters;
|
|
55
55
|
this.filterStacktraces = filterStacktraces;
|
|
56
|
-
this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(options.dryRun, this.supportCodeLibrary.defaultTimeout, (name, location) => `${name} hook errored on worker ${this.id}, process exiting: ${location}`);
|
|
56
|
+
this.runTestRunHooks = (0, run_test_run_hooks_1.makeRunTestRunHooks)(options.dryRun, this.supportCodeLibrary.defaultTimeout, this.worldParameters, (name, location) => `${name} hook errored on worker ${this.id}, process exiting: ${location}`);
|
|
57
57
|
await this.runTestRunHooks(this.supportCodeLibrary.beforeTestRunHookDefinitions, 'a BeforeAll');
|
|
58
58
|
this.sendMessage({ ready: true });
|
|
59
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/worker.ts"],"names":[],"mappings":";;;;;AAAA,6CAA0C;AAC1C,uCAAwC;AAExC,iDAAgD;
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../../src/runtime/parallel/worker.ts"],"names":[],"mappings":";;;;;AAAA,6CAA0C;AAC1C,uCAAwC;AAExC,iDAAgD;AAEhD,sGAA0E;AAE1E,uDAAmD;AACnD,8DAA6E;AAC7E,4CAAqC;AACrC,2EAAgD;AAChD,oEAA0C;AAQ1C,MAAM,EAAE,IAAI,EAAE,GAAG,sBAAW,CAAA;AAK5B,MAAqB,MAAM;IACR,GAAG,CAAQ;IACX,IAAI,CAAe;IAEnB,EAAE,CAAQ;IACV,gBAAgB,CAAc;IACvC,iBAAiB,CAAS;IACjB,KAAK,CAAmB;IACxB,WAAW,CAAgB;IACpC,kBAAkB,CAAqB;IACvC,eAA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AC,CAAA;SACpC;IACH,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,EAChB,eAAe,EACf,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,EACP,IAAI,GACc;QAClB,MAAM,SAAS,GAAG,IAAA,kBAAM,EAAC,OAAO,CAAC,CAAA;QACjC,MAAM,cAAc,GAAG,IAAI,0BAAc,CAAC;YACxC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,SAAS;YACT,eAAe;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM;YACN,QAAQ;YACR,OAAO;YACP,IAAI;YACJ,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAA;QACF,MAAM,cAAc,CAAC,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACnC,CAAC;CACF;AAtHD,yBAsHC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { pathToFileURL } from 'node:url'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { JsonObject } from 'type-fest'\nimport supportCodeLibraryBuilder from '../../support_code_library_builder'\nimport { ISupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { doesHaveValue } from '../../value_checker'\nimport { makeRunTestRunHooks, RunsTestRunHooks } from '../run_test_run_hooks'\nimport { create } from '../stopwatch'\nimport TestCaseRunner from '../test_case_runner'\nimport tryRequire from '../../try_require'\nimport {\n ICoordinatorReport,\n IWorkerCommand,\n IWorkerCommandInitialize,\n IWorkerCommandRun,\n} from './command_types'\n\nconst { uuid } = IdGenerator\n\ntype IExitFunction = (exitCode: number, error?: Error, message?: string) => void\ntype IMessageSender = (command: ICoordinatorReport) => void\n\nexport default class Worker {\n private readonly cwd: string\n private readonly exit: IExitFunction\n\n private readonly id: string\n private readonly eventBroadcaster: EventEmitter\n private filterStacktraces: boolean\n private readonly newId: IdGenerator.NewId\n private readonly sendMessage: IMessageSender\n private supportCodeLibrary: ISupportCodeLibrary\n private worldParameters: JsonObject\n private runTestRunHooks: RunsTestRunHooks\n\n constructor({\n cwd,\n exit,\n id,\n sendMessage,\n }: {\n cwd: string\n exit: IExitFunction\n id: string\n sendMessage: IMessageSender\n }) {\n this.id = id\n this.newId = uuid()\n this.cwd = cwd\n this.exit = exit\n this.sendMessage = sendMessage\n this.eventBroadcaster = new EventEmitter()\n this.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n // assign `workerId` property only for the `testCaseStarted` message\n if (envelope.testCaseStarted) {\n envelope.testCaseStarted.workerId = this.id\n }\n this.sendMessage({ jsonEnvelope: JSON.stringify(envelope) })\n })\n }\n\n async initialize({\n filterStacktraces,\n requireModules,\n requirePaths,\n importPaths,\n supportCodeIds,\n options,\n }: IWorkerCommandInitialize): Promise<void> {\n supportCodeLibraryBuilder.reset(this.cwd, this.newId, {\n requireModules,\n requirePaths,\n importPaths,\n })\n requireModules.map((module) => tryRequire(module))\n requirePaths.map((module) => tryRequire(module))\n for (const path of importPaths) {\n await import(pathToFileURL(path).toString())\n }\n this.supportCodeLibrary = supportCodeLibraryBuilder.finalize(supportCodeIds)\n\n this.worldParameters = options.worldParameters\n this.filterStacktraces = filterStacktraces\n this.runTestRunHooks = makeRunTestRunHooks(\n options.dryRun,\n this.supportCodeLibrary.defaultTimeout,\n this.worldParameters,\n (name, location) =>\n `${name} hook errored on worker ${this.id}, process exiting: ${location}`\n )\n await this.runTestRunHooks(\n this.supportCodeLibrary.beforeTestRunHookDefinitions,\n 'a BeforeAll'\n )\n this.sendMessage({ ready: true })\n }\n\n async finalize(): Promise<void> {\n await this.runTestRunHooks(\n this.supportCodeLibrary.afterTestRunHookDefinitions,\n 'an AfterAll'\n )\n this.exit(0)\n }\n\n async receiveMessage(message: IWorkerCommand): Promise<void> {\n if (doesHaveValue(message.initialize)) {\n await this.initialize(message.initialize)\n } else if (message.finalize) {\n await this.finalize()\n } else if (doesHaveValue(message.run)) {\n await this.runTestCase(message.run)\n }\n }\n\n async runTestCase({\n gherkinDocument,\n pickle,\n testCase,\n elapsed,\n retries,\n skip,\n }: IWorkerCommandRun): Promise<void> {\n const stopwatch = create(elapsed)\n const testCaseRunner = new TestCaseRunner({\n eventBroadcaster: this.eventBroadcaster,\n stopwatch,\n gherkinDocument,\n newId: this.newId,\n pickle,\n testCase,\n retries,\n skip,\n filterStackTraces: this.filterStacktraces,\n supportCodeLibrary: this.supportCodeLibrary,\n worldParameters: this.worldParameters,\n })\n await testCaseRunner.run()\n this.sendMessage({ ready: true })\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JsonObject } from 'type-fest';
|
|
1
2
|
import TestRunHookDefinition from '../models/test_run_hook_definition';
|
|
2
3
|
export type RunsTestRunHooks = (definitions: TestRunHookDefinition[], name: string) => Promise<void>;
|
|
3
|
-
export declare const makeRunTestRunHooks: (dryRun: boolean, defaultTimeout: number, errorMessage: (name: string, location: string) => string) => RunsTestRunHooks;
|
|
4
|
+
export declare const makeRunTestRunHooks: (dryRun: boolean, defaultTimeout: number, worldParameters: JsonObject, errorMessage: (name: string, location: string) => string) => RunsTestRunHooks;
|
|
@@ -4,23 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeRunTestRunHooks = void 0;
|
|
7
|
-
const verror_1 = __importDefault(require("verror"));
|
|
8
7
|
const user_code_runner_1 = __importDefault(require("../user_code_runner"));
|
|
9
8
|
const helpers_1 = require("../formatter/helpers");
|
|
10
9
|
const value_checker_1 = require("../value_checker");
|
|
11
|
-
const makeRunTestRunHooks = (dryRun, defaultTimeout, errorMessage) => dryRun
|
|
10
|
+
const makeRunTestRunHooks = (dryRun, defaultTimeout, worldParameters, errorMessage) => dryRun
|
|
12
11
|
? async () => { }
|
|
13
12
|
: async (definitions, name) => {
|
|
14
13
|
for (const hookDefinition of definitions) {
|
|
15
14
|
const { error } = await user_code_runner_1.default.run({
|
|
16
15
|
argsArray: [],
|
|
17
16
|
fn: hookDefinition.code,
|
|
18
|
-
thisArg:
|
|
17
|
+
thisArg: { parameters: worldParameters },
|
|
19
18
|
timeoutInMilliseconds: (0, value_checker_1.valueOrDefault)(hookDefinition.options.timeout, defaultTimeout),
|
|
20
19
|
});
|
|
21
20
|
if ((0, value_checker_1.doesHaveValue)(error)) {
|
|
22
21
|
const location = (0, helpers_1.formatLocation)(hookDefinition);
|
|
23
|
-
throw new
|
|
22
|
+
throw new Error(errorMessage(name, location), { cause: error });
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run_test_run_hooks.js","sourceRoot":"","sources":["../../src/runtime/run_test_run_hooks.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"run_test_run_hooks.js","sourceRoot":"","sources":["../../src/runtime/run_test_run_hooks.ts"],"names":[],"mappings":";;;;;;AACA,2EAAgD;AAChD,kDAAqD;AACrD,oDAAgE;AAQzD,MAAM,mBAAmB,GAAG,CACjC,MAAe,EACf,cAAsB,EACtB,eAA2B,EAC3B,YAAwD,EACtC,EAAE,CACpB,MAAM;IACJ,CAAC,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC;IAChB,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;QAC1B,KAAK,MAAM,cAAc,IAAI,WAAW,EAAE;YACxC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,0BAAc,CAAC,GAAG,CAAC;gBACzC,SAAS,EAAE,EAAE;gBACb,EAAE,EAAE,cAAc,CAAC,IAAI;gBACvB,OAAO,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE;gBACxC,qBAAqB,EAAE,IAAA,8BAAc,EACnC,cAAc,CAAC,OAAO,CAAC,OAAO,EAC9B,cAAc,CACf;aACF,CAAC,CAAA;YACF,IAAI,IAAA,6BAAa,EAAC,KAAK,CAAC,EAAE;gBACxB,MAAM,QAAQ,GAAG,IAAA,wBAAc,EAAC,cAAc,CAAC,CAAA;gBAC/C,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;aAChE;SACF;IACH,CAAC,CAAA;AAxBM,QAAA,mBAAmB,uBAwBzB","sourcesContent":["import { JsonObject } from 'type-fest'\nimport UserCodeRunner from '../user_code_runner'\nimport { formatLocation } from '../formatter/helpers'\nimport { doesHaveValue, valueOrDefault } from '../value_checker'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\n\nexport type RunsTestRunHooks = (\n definitions: TestRunHookDefinition[],\n name: string\n) => Promise<void>\n\nexport const makeRunTestRunHooks = (\n dryRun: boolean,\n defaultTimeout: number,\n worldParameters: JsonObject,\n errorMessage: (name: string, location: string) => string\n): RunsTestRunHooks =>\n dryRun\n ? async () => {}\n : async (definitions, name) => {\n for (const hookDefinition of definitions) {\n const { error } = await UserCodeRunner.run({\n argsArray: [],\n fn: hookDefinition.code,\n thisArg: { parameters: worldParameters },\n timeoutInMilliseconds: valueOrDefault(\n hookDefinition.options.timeout,\n defaultTimeout\n ),\n })\n if (doesHaveValue(error)) {\n const location = formatLocation(hookDefinition)\n throw new Error(errorMessage(name, location), { cause: error })\n }\n }\n }\n"]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import * as messages from '@cucumber/messages';
|
|
4
4
|
import { IdGenerator } from '@cucumber/messages';
|
|
5
|
+
import { JsonObject } from 'type-fest';
|
|
5
6
|
import { ISupportCodeLibrary, ITestCaseHookParameter } from '../support_code_library_builder/types';
|
|
6
7
|
import TestCaseHookDefinition from '../models/test_case_hook_definition';
|
|
7
8
|
import TestStepHookDefinition from '../models/test_step_hook_definition';
|
|
@@ -18,7 +19,7 @@ export interface INewTestCaseRunnerOptions {
|
|
|
18
19
|
skip: boolean;
|
|
19
20
|
filterStackTraces: boolean;
|
|
20
21
|
supportCodeLibrary: ISupportCodeLibrary;
|
|
21
|
-
worldParameters:
|
|
22
|
+
worldParameters: JsonObject;
|
|
22
23
|
}
|
|
23
24
|
export default class TestCaseRunner {
|
|
24
25
|
private readonly attachmentManager;
|