@lynxwall/cucumber-tsflow 7.7.0 → 7.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/loader-worker.d.ts +13 -0
- package/lib/api/loader-worker.js +185 -11
- package/lib/api/loader-worker.js.map +1 -1
- package/lib/api/parallel-loader.js +18 -1
- package/lib/api/parallel-loader.js.map +1 -1
- package/lib/api/run-cucumber.js.map +1 -1
- package/lib/bindings/binding-decorator.js.map +1 -1
- package/lib/bindings/step-decorators.js.map +1 -1
- package/lib/runtime/worker.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 +1 -1
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* loader-worker.ts
|
|
3
|
+
*
|
|
4
|
+
* Runs inside a worker_threads Worker. Receives support-code file paths and
|
|
5
|
+
* transpiler configuration, loads the files (warming the transpiler cache),
|
|
6
|
+
* extracts serializable binding descriptors from the BindingRegistry, and
|
|
7
|
+
* posts them back to the main thread.
|
|
8
|
+
*
|
|
9
|
+
* The __LOADER_WORKER global flag causes the binding decorator to skip
|
|
10
|
+
* Cucumber step/hook registration — only BindingRegistry population occurs.
|
|
11
|
+
*/
|
|
1
12
|
import 'polyfill-symbol-metadata';
|
|
2
13
|
/** Message types sent from main thread to worker */
|
|
3
14
|
export interface LoaderWorkerRequest {
|
|
@@ -22,4 +33,6 @@ export interface LoaderWorkerResponse {
|
|
|
22
33
|
loadedFiles?: string[];
|
|
23
34
|
/** Error message if something went wrong */
|
|
24
35
|
error?: string;
|
|
36
|
+
/** Per-file errors that were caught but did not kill the worker */
|
|
37
|
+
fileErrors?: string[];
|
|
25
38
|
}
|
package/lib/api/loader-worker.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
2
|
/**
|
|
4
3
|
* loader-worker.ts
|
|
5
4
|
*
|
|
@@ -11,6 +10,167 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
10
|
* The __LOADER_WORKER global flag causes the binding decorator to skip
|
|
12
11
|
* Cucumber step/hook registration — only BindingRegistry population occurs.
|
|
13
12
|
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
// Shim browser globals for libraries that expect a browser environment in worker threads.
|
|
15
|
+
// Workers are a constrained Node.js environment — many libraries probe for browser APIs
|
|
16
|
+
// during module evaluation. These stubs prevent "Cannot read properties of undefined" errors.
|
|
17
|
+
// Aligned with the globals expected by @uis/testing-bdd (uis-jest setup).
|
|
18
|
+
if (typeof globalThis.window === 'undefined') {
|
|
19
|
+
const noop = () => { };
|
|
20
|
+
const noopObj = new Proxy({}, { get: () => noop });
|
|
21
|
+
// Helper: safely set a global property (some like `navigator` are getter-only in modern Node)
|
|
22
|
+
const safeDefine = (target, key, value) => {
|
|
23
|
+
try {
|
|
24
|
+
Object.defineProperty(target, key, { value, writable: true, configurable: true });
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Property may be non-configurable — ignore and move on
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
// Minimal location stub — covers window.location.href / .origin / .protocol etc.
|
|
31
|
+
const locationStub = {
|
|
32
|
+
href: '',
|
|
33
|
+
origin: '',
|
|
34
|
+
protocol: 'file:',
|
|
35
|
+
host: '',
|
|
36
|
+
hostname: '',
|
|
37
|
+
port: '',
|
|
38
|
+
pathname: '',
|
|
39
|
+
search: '',
|
|
40
|
+
hash: '',
|
|
41
|
+
assign: noop,
|
|
42
|
+
replace: noop,
|
|
43
|
+
reload: noop,
|
|
44
|
+
toString: () => ''
|
|
45
|
+
};
|
|
46
|
+
// Minimal document stub — covers document.createElement, querySelector, etc.
|
|
47
|
+
const documentStub = {
|
|
48
|
+
createElement: () => noopObj,
|
|
49
|
+
createElementNS: () => noopObj,
|
|
50
|
+
createTextNode: () => noopObj,
|
|
51
|
+
createDocumentFragment: () => noopObj,
|
|
52
|
+
createComment: () => noopObj,
|
|
53
|
+
getElementById: () => null,
|
|
54
|
+
getElementsByClassName: () => [],
|
|
55
|
+
getElementsByTagName: () => [],
|
|
56
|
+
querySelector: () => null,
|
|
57
|
+
querySelectorAll: () => [],
|
|
58
|
+
head: noopObj,
|
|
59
|
+
body: noopObj,
|
|
60
|
+
documentElement: noopObj,
|
|
61
|
+
addEventListener: noop,
|
|
62
|
+
removeEventListener: noop,
|
|
63
|
+
dispatchEvent: noop,
|
|
64
|
+
cookie: ''
|
|
65
|
+
};
|
|
66
|
+
// Minimal navigator stub
|
|
67
|
+
const navigatorStub = {
|
|
68
|
+
userAgent: 'node',
|
|
69
|
+
platform: process.platform,
|
|
70
|
+
language: 'en',
|
|
71
|
+
languages: ['en']
|
|
72
|
+
};
|
|
73
|
+
// Fake localStorage — matches @uis/testing-bdd FakeLocalStorage
|
|
74
|
+
const localStorageStub = {
|
|
75
|
+
store: {},
|
|
76
|
+
clear() {
|
|
77
|
+
this.store = {};
|
|
78
|
+
},
|
|
79
|
+
getItem(key) {
|
|
80
|
+
return this.store[key] ?? null;
|
|
81
|
+
},
|
|
82
|
+
setItem(key, value) {
|
|
83
|
+
this.store[key] = value;
|
|
84
|
+
},
|
|
85
|
+
removeItem(key) {
|
|
86
|
+
delete this.store[key];
|
|
87
|
+
},
|
|
88
|
+
get length() {
|
|
89
|
+
return Object.keys(this.store).length;
|
|
90
|
+
},
|
|
91
|
+
key() {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
// matchMedia stub — matches @uis/testing-bdd mock
|
|
96
|
+
const matchMediaStub = (query) => ({
|
|
97
|
+
matches: false,
|
|
98
|
+
media: query,
|
|
99
|
+
onchange: null,
|
|
100
|
+
addListener: noop,
|
|
101
|
+
removeListener: noop,
|
|
102
|
+
addEventListener: noop,
|
|
103
|
+
removeEventListener: noop,
|
|
104
|
+
dispatchEvent: noop
|
|
105
|
+
});
|
|
106
|
+
// Minimal Element prototype for scrollIntoView etc.
|
|
107
|
+
class HTMLElementStub {
|
|
108
|
+
scrollIntoView = noop;
|
|
109
|
+
getBoundingClientRect = () => ({
|
|
110
|
+
top: 0,
|
|
111
|
+
left: 0,
|
|
112
|
+
bottom: 0,
|
|
113
|
+
right: 0,
|
|
114
|
+
width: 0,
|
|
115
|
+
height: 0,
|
|
116
|
+
x: 0,
|
|
117
|
+
y: 0
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
class ElementStub extends HTMLElementStub {
|
|
121
|
+
}
|
|
122
|
+
// Minimal XMLSerializer stub
|
|
123
|
+
class XMLSerializerStub {
|
|
124
|
+
serializeToString() {
|
|
125
|
+
return '';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// Build the window shim
|
|
129
|
+
const windowShim = {};
|
|
130
|
+
for (const key of Object.getOwnPropertyNames(globalThis)) {
|
|
131
|
+
try {
|
|
132
|
+
windowShim[key] = globalThis[key];
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// skip non-readable properties
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
windowShim.location = locationStub;
|
|
139
|
+
windowShim.document = documentStub;
|
|
140
|
+
windowShim.navigator = navigatorStub;
|
|
141
|
+
windowShim.localStorage = localStorageStub;
|
|
142
|
+
windowShim.self = windowShim;
|
|
143
|
+
windowShim.top = windowShim;
|
|
144
|
+
windowShim.parent = windowShim;
|
|
145
|
+
windowShim.addEventListener = noop;
|
|
146
|
+
windowShim.removeEventListener = noop;
|
|
147
|
+
windowShim.dispatchEvent = noop;
|
|
148
|
+
windowShim.requestAnimationFrame = noop;
|
|
149
|
+
windowShim.cancelAnimationFrame = noop;
|
|
150
|
+
windowShim.getComputedStyle = () => noopObj;
|
|
151
|
+
windowShim.matchMedia = matchMediaStub;
|
|
152
|
+
windowShim.open = noop;
|
|
153
|
+
windowShim.close = noop;
|
|
154
|
+
windowShim.focus = noop;
|
|
155
|
+
windowShim.blur = noop;
|
|
156
|
+
windowShim.scroll = noop;
|
|
157
|
+
windowShim.scrollTo = noop;
|
|
158
|
+
windowShim.scrollBy = noop;
|
|
159
|
+
windowShim.CustomEvent = class CustomEvent extends Event {
|
|
160
|
+
};
|
|
161
|
+
windowShim.HTMLElement = HTMLElementStub;
|
|
162
|
+
windowShim.Element = ElementStub;
|
|
163
|
+
windowShim.XMLSerializer = XMLSerializerStub;
|
|
164
|
+
// Set globals on globalThis
|
|
165
|
+
safeDefine(globalThis, 'window', windowShim);
|
|
166
|
+
safeDefine(globalThis, 'document', documentStub);
|
|
167
|
+
safeDefine(globalThis, 'navigator', navigatorStub);
|
|
168
|
+
safeDefine(globalThis, 'location', locationStub);
|
|
169
|
+
safeDefine(globalThis, 'localStorage', localStorageStub);
|
|
170
|
+
safeDefine(globalThis, 'self', windowShim);
|
|
171
|
+
safeDefine(globalThis, 'matchMedia', matchMediaStub);
|
|
172
|
+
safeDefine(globalThis, 'XMLSerializer', XMLSerializerStub);
|
|
173
|
+
}
|
|
14
174
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
15
175
|
const node_module_1 = require("node:module");
|
|
16
176
|
const node_url_1 = require("node:url");
|
|
@@ -21,25 +181,36 @@ async function processMessage(message) {
|
|
|
21
181
|
if (message.type !== 'LOAD') {
|
|
22
182
|
return;
|
|
23
183
|
}
|
|
184
|
+
const fileErrors = [];
|
|
24
185
|
try {
|
|
25
186
|
// Set the experimental decorators flag before loading support code
|
|
26
187
|
global.experimentalDecorators = message.experimentalDecorators;
|
|
27
188
|
process.env.CUCUMBER_EXPERIMENTAL_DECORATORS = String(message.experimentalDecorators);
|
|
28
|
-
// Load require modules (transpiler setup)
|
|
189
|
+
// Load require modules (transpiler setup) — these are critical, fail fast
|
|
29
190
|
for (const modulePath of message.requireModules) {
|
|
30
191
|
require(modulePath);
|
|
31
192
|
}
|
|
32
|
-
//
|
|
33
|
-
for (const filePath of message.requirePaths) {
|
|
34
|
-
require(filePath);
|
|
35
|
-
}
|
|
36
|
-
// Register ESM loaders
|
|
193
|
+
// Register ESM loaders — also critical for import phase
|
|
37
194
|
for (const specifier of message.loaders) {
|
|
38
195
|
(0, node_module_1.register)(specifier, (0, node_url_1.pathToFileURL)('./'));
|
|
39
196
|
}
|
|
40
|
-
// Load support files via
|
|
197
|
+
// Load support files via require (CJS) — per-file isolation
|
|
198
|
+
for (const filePath of message.requirePaths) {
|
|
199
|
+
try {
|
|
200
|
+
require(filePath);
|
|
201
|
+
}
|
|
202
|
+
catch (err) {
|
|
203
|
+
fileErrors.push(`CJS ${filePath}: ${err.message || String(err)}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
// Load support files via import (ESM) — per-file isolation
|
|
41
207
|
for (const filePath of message.importPaths) {
|
|
42
|
-
|
|
208
|
+
try {
|
|
209
|
+
await import((0, node_url_1.pathToFileURL)(filePath).toString());
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
fileErrors.push(`ESM ${filePath}: ${err.message || String(err)}`);
|
|
213
|
+
}
|
|
43
214
|
}
|
|
44
215
|
// Extract descriptors from the binding registry
|
|
45
216
|
const { BindingRegistry } = require('../bindings/binding-registry');
|
|
@@ -49,14 +220,17 @@ async function processMessage(message) {
|
|
|
49
220
|
const response = {
|
|
50
221
|
type: 'LOADED',
|
|
51
222
|
descriptors,
|
|
52
|
-
loadedFiles
|
|
223
|
+
loadedFiles,
|
|
224
|
+
fileErrors: fileErrors.length > 0 ? fileErrors : undefined
|
|
53
225
|
};
|
|
54
226
|
node_worker_threads_1.parentPort.postMessage(response);
|
|
55
227
|
}
|
|
56
228
|
catch (err) {
|
|
229
|
+
// Critical failure (transpiler setup / loader registration / registry extraction)
|
|
57
230
|
const response = {
|
|
58
231
|
type: 'ERROR',
|
|
59
|
-
error: err.message || String(err)
|
|
232
|
+
error: err.message || String(err),
|
|
233
|
+
fileErrors: fileErrors.length > 0 ? fileErrors : undefined
|
|
60
234
|
};
|
|
61
235
|
node_worker_threads_1.parentPort.postMessage(response);
|
|
62
236
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-worker.js","sourceRoot":"","sources":["../../src/api/loader-worker.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;GAUG;AACH,6DAA6D;AAC7D,6CAAuC;AACvC,uCAAyC;AACzC,oCAAkC;AAElC,gFAAgF;AAC/E,MAAc,CAAC,eAAe,GAAG,IAAI,CAAC;AA4BvC,KAAK,UAAU,cAAc,CAAC,OAA4B;IACzD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC7B,OAAO;IACR,CAAC;IAED,IAAI,CAAC;QACJ,mEAAmE;QACnE,MAAM,CAAC,sBAAsB,GAAG,OAAO,CAAC,sBAAsB,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,gCAAgC,GAAG,MAAM,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAEtF,0CAA0C;QAC1C,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YACjD,OAAO,CAAC,UAAU,CAAC,CAAC;QACrB,CAAC;QAED,uCAAuC;QACvC,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YAC7C,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnB,CAAC;QAED,uBAAuB;QACvB,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACzC,IAAA,sBAAQ,EAAC,SAAS,EAAE,IAAA,wBAAa,EAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,CAAC;QAED,sCAAsC;QACtC,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YAC5C,MAAM,MAAM,CAAC,IAAA,wBAAa,EAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,gDAAgD;QAChD,MAAM,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;QACpE,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC;QAC1C,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC7C,MAAM,WAAW,GAAa,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAAwB,EAAE,CAAC,CAAC;QAE9E,MAAM,QAAQ,GAAyB;YACtC,IAAI,EAAE,QAAQ;YACd,WAAW;YACX,WAAW;SACX,CAAC;QACF,gCAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAyB;YACtC,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC;SACjC,CAAC;QACF,gCAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;AACF,CAAC;AAED,uEAAuE;AACvE,IAAI,gCAAU,IAAI,gCAAU,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC9C,cAAc,CAAC,gCAAiC,CAAC,CAAC;AACnD,CAAC;AAED,4CAA4C;AAC5C,gCAAU,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,GAAwB,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC","sourcesContent":["/**\r\n * loader-worker.ts\r\n *\r\n * Runs inside a worker_threads Worker. Receives support-code file paths and\r\n * transpiler configuration, loads the files (warming the transpiler cache),\r\n * extracts serializable binding descriptors from the BindingRegistry, and\r\n * posts them back to the main thread.\r\n *\r\n * The __LOADER_WORKER global flag causes the binding decorator to skip\r\n * Cucumber step/hook registration — only BindingRegistry population occurs.\r\n */\r\nimport { parentPort, workerData } from 'node:worker_threads';\r\nimport { register } from 'node:module';\r\nimport { pathToFileURL } from 'node:url';\r\nimport 'polyfill-symbol-metadata';\r\n\r\n// Signal that we're in a loader-worker context so decorators skip Cucumber APIs\r\n(global as any).__LOADER_WORKER = true;\r\n\r\n/** Message types sent from main thread to worker */\r\nexport interface LoaderWorkerRequest {\r\n\ttype: 'LOAD';\r\n\t/** Absolute paths to load via require() */\r\n\trequirePaths: string[];\r\n\t/** Absolute paths to load via import() */\r\n\timportPaths: string[];\r\n\t/** Modules to require before support code (transpiler setup etc.) */\r\n\trequireModules: string[];\r\n\t/** ESM loaders to register before importing */\r\n\tloaders: string[];\r\n\t/** Whether to use experimental decorators */\r\n\texperimentalDecorators: boolean;\r\n}\r\n\r\n/** Message types sent from worker back to main thread */\r\nexport interface LoaderWorkerResponse {\r\n\ttype: 'LOADED' | 'ERROR';\r\n\t/** Serializable binding descriptors extracted from the registry */\r\n\tdescriptors?: import('../bindings/step-binding').SerializableBindingDescriptor[];\r\n\t/** Source files that were successfully loaded */\r\n\tloadedFiles?: string[];\r\n\t/** Error message if something went wrong */\r\n\terror?: string;\r\n}\r\n\r\nasync function processMessage(message: LoaderWorkerRequest): Promise<void> {\r\n\tif (message.type !== 'LOAD') {\r\n\t\treturn;\r\n\t}\r\n\r\n\ttry {\r\n\t\t// Set the experimental decorators flag before loading support code\r\n\t\tglobal.experimentalDecorators = message.experimentalDecorators;\r\n\t\tprocess.env.CUCUMBER_EXPERIMENTAL_DECORATORS = String(message.experimentalDecorators);\r\n\r\n\t\t// Load require modules (transpiler setup)\r\n\t\tfor (const modulePath of message.requireModules) {\r\n\t\t\trequire(modulePath);\r\n\t\t}\r\n\r\n\t\t// Load support files via require (CJS)\r\n\t\tfor (const filePath of message.requirePaths) {\r\n\t\t\trequire(filePath);\r\n\t\t}\r\n\r\n\t\t// Register ESM loaders\r\n\t\tfor (const specifier of message.loaders) {\r\n\t\t\tregister(specifier, pathToFileURL('./'));\r\n\t\t}\r\n\r\n\t\t// Load support files via import (ESM)\r\n\t\tfor (const filePath of message.importPaths) {\r\n\t\t\tawait import(pathToFileURL(filePath).toString());\r\n\t\t}\r\n\r\n\t\t// Extract descriptors from the binding registry\r\n\t\tconst { BindingRegistry } = require('../bindings/binding-registry');\r\n\t\tconst registry = BindingRegistry.instance;\r\n\t\tconst descriptors = registry.toDescriptors();\r\n\t\tconst loadedFiles: string[] = Array.from(registry.getDescriptorSourceFiles());\r\n\r\n\t\tconst response: LoaderWorkerResponse = {\r\n\t\t\ttype: 'LOADED',\r\n\t\t\tdescriptors,\r\n\t\t\tloadedFiles\r\n\t\t};\r\n\t\tparentPort!.postMessage(response);\r\n\t} catch (err: any) {\r\n\t\tconst response: LoaderWorkerResponse = {\r\n\t\t\ttype: 'ERROR',\r\n\t\t\terror: err.message || String(err)\r\n\t\t};\r\n\t\tparentPort!.postMessage(response);\r\n\t}\r\n}\r\n\r\n// Handle initial workerData (if files are passed at construction time)\r\nif (workerData && workerData.type === 'LOAD') {\r\n\tprocessMessage(workerData as LoaderWorkerRequest);\r\n}\r\n\r\n// Handle messages posted after construction\r\nparentPort?.on('message', (msg: LoaderWorkerRequest) => processMessage(msg));\r\n"]}
|
|
1
|
+
{"version":3,"file":"loader-worker.js","sourceRoot":"","sources":["../../src/api/loader-worker.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;AAEH,0FAA0F;AAC1F,wFAAwF;AACxF,8FAA8F;AAC9F,0EAA0E;AAC1E,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;IAC9C,MAAM,IAAI,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;IAC5B,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;IAEnD,8FAA8F;IAC9F,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,GAAW,EAAE,KAAc,EAAQ,EAAE;QACxE,IAAI,CAAC;YACJ,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,I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AW,GAAG,QAAQ,CAAC,aAAa,EAAE,CAAC;QAC7C,MAAM,WAAW,GAAa,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAAwB,EAAE,CAAC,CAAC;QAE9E,MAAM,QAAQ,GAAyB;YACtC,IAAI,EAAE,QAAQ;YACd,WAAW;YACX,WAAW;YACX,UAAU,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;SAC1D,CAAC;QACF,gCAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QACnB,kFAAkF;QAClF,MAAM,QAAQ,GAAyB;YACtC,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC;YACjC,UAAU,EAAE,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;SAC1D,CAAC;QACF,gCAAW,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;AACF,CAAC;AAED,uEAAuE;AACvE,IAAI,gCAAU,IAAI,gCAAU,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC9C,cAAc,CAAC,gCAAiC,CAAC,CAAC;AACnD,CAAC;AAED,4CAA4C;AAC5C,gCAAU,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,GAAwB,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC","sourcesContent":["/**\r\n * loader-worker.ts\r\n *\r\n * Runs inside a worker_threads Worker. Receives support-code file paths and\r\n * transpiler configuration, loads the files (warming the transpiler cache),\r\n * extracts serializable binding descriptors from the BindingRegistry, and\r\n * posts them back to the main thread.\r\n *\r\n * The __LOADER_WORKER global flag causes the binding decorator to skip\r\n * Cucumber step/hook registration — only BindingRegistry population occurs.\r\n */\r\n\r\n// Shim browser globals for libraries that expect a browser environment in worker threads.\r\n// Workers are a constrained Node.js environment — many libraries probe for browser APIs\r\n// during module evaluation. These stubs prevent \"Cannot read properties of undefined\" errors.\r\n// Aligned with the globals expected by @uis/testing-bdd (uis-jest setup).\r\nif (typeof globalThis.window === 'undefined') {\r\n\tconst noop = (): void => {};\r\n\tconst noopObj = new Proxy({}, { get: () => noop });\r\n\r\n\t// Helper: safely set a global property (some like `navigator` are getter-only in modern Node)\r\n\tconst safeDefine = (target: object, key: string, value: unknown): void => {\r\n\t\ttry {\r\n\t\t\tObject.defineProperty(target, key, { value, writable: true, configurable: true });\r\n\t\t} catch {\r\n\t\t\t// Property may be non-configurable — ignore and move on\r\n\t\t}\r\n\t};\r\n\r\n\t// Minimal location stub — covers window.location.href / .origin / .protocol etc.\r\n\tconst locationStub = {\r\n\t\thref: '',\r\n\t\torigin: '',\r\n\t\tprotocol: 'file:',\r\n\t\thost: '',\r\n\t\thostname: '',\r\n\t\tport: '',\r\n\t\tpathname: '',\r\n\t\tsearch: '',\r\n\t\thash: '',\r\n\t\tassign: noop,\r\n\t\treplace: noop,\r\n\t\treload: noop,\r\n\t\ttoString: () => ''\r\n\t};\r\n\r\n\t// Minimal document stub — covers document.createElement, querySelector, etc.\r\n\tconst documentStub = {\r\n\t\tcreateElement: (): unknown => noopObj,\r\n\t\tcreateElementNS: (): unknown => noopObj,\r\n\t\tcreateTextNode: (): unknown => noopObj,\r\n\t\tcreateDocumentFragment: (): unknown => noopObj,\r\n\t\tcreateComment: (): unknown => noopObj,\r\n\t\tgetElementById: (): null => null,\r\n\t\tgetElementsByClassName: (): unknown[] => [],\r\n\t\tgetElementsByTagName: (): unknown[] => [],\r\n\t\tquerySelector: (): null => null,\r\n\t\tquerySelectorAll: (): unknown[] => [],\r\n\t\thead: noopObj,\r\n\t\tbody: noopObj,\r\n\t\tdocumentElement: noopObj,\r\n\t\taddEventListener: noop,\r\n\t\tremoveEventListener: noop,\r\n\t\tdispatchEvent: noop,\r\n\t\tcookie: ''\r\n\t};\r\n\r\n\t// Minimal navigator stub\r\n\tconst navigatorStub = {\r\n\t\tuserAgent: 'node',\r\n\t\tplatform: process.platform,\r\n\t\tlanguage: 'en',\r\n\t\tlanguages: ['en']\r\n\t};\r\n\r\n\t// Fake localStorage — matches @uis/testing-bdd FakeLocalStorage\r\n\tconst localStorageStub = {\r\n\t\tstore: {} as Record<string, string>,\r\n\t\tclear(): void {\r\n\t\t\tthis.store = {};\r\n\t\t},\r\n\t\tgetItem(key: string): string | null {\r\n\t\t\treturn this.store[key] ?? null;\r\n\t\t},\r\n\t\tsetItem(key: string, value: string): void {\r\n\t\t\tthis.store[key] = value;\r\n\t\t},\r\n\t\tremoveItem(key: string): void {\r\n\t\t\tdelete this.store[key];\r\n\t\t},\r\n\t\tget length(): number {\r\n\t\t\treturn Object.keys(this.store).length;\r\n\t\t},\r\n\t\tkey(): null {\r\n\t\t\treturn null;\r\n\t\t}\r\n\t};\r\n\r\n\t// matchMedia stub — matches @uis/testing-bdd mock\r\n\tconst matchMediaStub = (query: string): Record<string, unknown> => ({\r\n\t\tmatches: false,\r\n\t\tmedia: query,\r\n\t\tonchange: null,\r\n\t\taddListener: noop,\r\n\t\tremoveListener: noop,\r\n\t\taddEventListener: noop,\r\n\t\tremoveEventListener: noop,\r\n\t\tdispatchEvent: noop\r\n\t});\r\n\r\n\t// Minimal Element prototype for scrollIntoView etc.\r\n\tclass HTMLElementStub {\r\n\t\tscrollIntoView = noop;\r\n\t\tgetBoundingClientRect = (): Record<string, number> => ({\r\n\t\t\ttop: 0,\r\n\t\t\tleft: 0,\r\n\t\t\tbottom: 0,\r\n\t\t\tright: 0,\r\n\t\t\twidth: 0,\r\n\t\t\theight: 0,\r\n\t\t\tx: 0,\r\n\t\t\ty: 0\r\n\t\t});\r\n\t}\r\n\tclass ElementStub extends HTMLElementStub {}\r\n\r\n\t// Minimal XMLSerializer stub\r\n\tclass XMLSerializerStub {\r\n\t\tserializeToString(): string {\r\n\t\t\treturn '';\r\n\t\t}\r\n\t}\r\n\r\n\t// Build the window shim\r\n\tconst windowShim: Record<string, unknown> = {};\r\n\tfor (const key of Object.getOwnPropertyNames(globalThis)) {\r\n\t\ttry {\r\n\t\t\t(windowShim as Record<string, unknown>)[key] = (globalThis as Record<string, unknown>)[key];\r\n\t\t} catch {\r\n\t\t\t// skip non-readable properties\r\n\t\t}\r\n\t}\r\n\r\n\twindowShim.location = locationStub;\r\n\twindowShim.document = documentStub;\r\n\twindowShim.navigator = navigatorStub;\r\n\twindowShim.localStorage = localStorageStub;\r\n\twindowShim.self = windowShim;\r\n\twindowShim.top = windowShim;\r\n\twindowShim.parent = windowShim;\r\n\twindowShim.addEventListener = noop;\r\n\twindowShim.removeEventListener = noop;\r\n\twindowShim.dispatchEvent = noop;\r\n\twindowShim.requestAnimationFrame = noop;\r\n\twindowShim.cancelAnimationFrame = noop;\r\n\twindowShim.getComputedStyle = () => noopObj;\r\n\twindowShim.matchMedia = matchMediaStub;\r\n\twindowShim.open = noop;\r\n\twindowShim.close = noop;\r\n\twindowShim.focus = noop;\r\n\twindowShim.blur = noop;\r\n\twindowShim.scroll = noop;\r\n\twindowShim.scrollTo = noop;\r\n\twindowShim.scrollBy = noop;\r\n\twindowShim.CustomEvent = class CustomEvent extends Event {};\r\n\twindowShim.HTMLElement = HTMLElementStub;\r\n\twindowShim.Element = ElementStub;\r\n\twindowShim.XMLSerializer = XMLSerializerStub;\r\n\r\n\t// Set globals on globalThis\r\n\tsafeDefine(globalThis, 'window', windowShim);\r\n\tsafeDefine(globalThis, 'document', documentStub);\r\n\tsafeDefine(globalThis, 'navigator', navigatorStub);\r\n\tsafeDefine(globalThis, 'location', locationStub);\r\n\tsafeDefine(globalThis, 'localStorage', localStorageStub);\r\n\tsafeDefine(globalThis, 'self', windowShim);\r\n\tsafeDefine(globalThis, 'matchMedia', matchMediaStub);\r\n\tsafeDefine(globalThis, 'XMLSerializer', XMLSerializerStub);\r\n}\r\n\r\nimport { parentPort, workerData } from 'node:worker_threads';\r\nimport { register } from 'node:module';\r\nimport { pathToFileURL } from 'node:url';\r\nimport 'polyfill-symbol-metadata';\r\n\r\n// Signal that we're in a loader-worker context so decorators skip Cucumber APIs\r\n(global as any).__LOADER_WORKER = true;\r\n\r\n/** Message types sent from main thread to worker */\r\nexport interface LoaderWorkerRequest {\r\n\ttype: 'LOAD';\r\n\t/** Absolute paths to load via require() */\r\n\trequirePaths: string[];\r\n\t/** Absolute paths to load via import() */\r\n\timportPaths: string[];\r\n\t/** Modules to require before support code (transpiler setup etc.) */\r\n\trequireModules: string[];\r\n\t/** ESM loaders to register before importing */\r\n\tloaders: string[];\r\n\t/** Whether to use experimental decorators */\r\n\texperimentalDecorators: boolean;\r\n}\r\n\r\n/** Message types sent from worker back to main thread */\r\nexport interface LoaderWorkerResponse {\r\n\ttype: 'LOADED' | 'ERROR';\r\n\t/** Serializable binding descriptors extracted from the registry */\r\n\tdescriptors?: import('../bindings/step-binding').SerializableBindingDescriptor[];\r\n\t/** Source files that were successfully loaded */\r\n\tloadedFiles?: string[];\r\n\t/** Error message if something went wrong */\r\n\terror?: string;\r\n\t/** Per-file errors that were caught but did not kill the worker */\r\n\tfileErrors?: string[];\r\n}\r\n\r\nasync function processMessage(message: LoaderWorkerRequest): Promise<void> {\r\n\tif (message.type !== 'LOAD') {\r\n\t\treturn;\r\n\t}\r\n\r\n\tconst fileErrors: string[] = [];\r\n\r\n\ttry {\r\n\t\t// Set the experimental decorators flag before loading support code\r\n\t\tglobal.experimentalDecorators = message.experimentalDecorators;\r\n\t\tprocess.env.CUCUMBER_EXPERIMENTAL_DECORATORS = String(message.experimentalDecorators);\r\n\r\n\t\t// Load require modules (transpiler setup) — these are critical, fail fast\r\n\t\tfor (const modulePath of message.requireModules) {\r\n\t\t\trequire(modulePath);\r\n\t\t}\r\n\r\n\t\t// Register ESM loaders — also critical for import phase\r\n\t\tfor (const specifier of message.loaders) {\r\n\t\t\tregister(specifier, pathToFileURL('./'));\r\n\t\t}\r\n\r\n\t\t// Load support files via require (CJS) — per-file isolation\r\n\t\tfor (const filePath of message.requirePaths) {\r\n\t\t\ttry {\r\n\t\t\t\trequire(filePath);\r\n\t\t\t} catch (err: any) {\r\n\t\t\t\tfileErrors.push(`CJS ${filePath}: ${err.message || String(err)}`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Load support files via import (ESM) — per-file isolation\r\n\t\tfor (const filePath of message.importPaths) {\r\n\t\t\ttry {\r\n\t\t\t\tawait import(pathToFileURL(filePath).toString());\r\n\t\t\t} catch (err: any) {\r\n\t\t\t\tfileErrors.push(`ESM ${filePath}: ${err.message || String(err)}`);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Extract descriptors from the binding registry\r\n\t\tconst { BindingRegistry } = require('../bindings/binding-registry');\r\n\t\tconst registry = BindingRegistry.instance;\r\n\t\tconst descriptors = registry.toDescriptors();\r\n\t\tconst loadedFiles: string[] = Array.from(registry.getDescriptorSourceFiles());\r\n\r\n\t\tconst response: LoaderWorkerResponse = {\r\n\t\t\ttype: 'LOADED',\r\n\t\t\tdescriptors,\r\n\t\t\tloadedFiles,\r\n\t\t\tfileErrors: fileErrors.length > 0 ? fileErrors : undefined\r\n\t\t};\r\n\t\tparentPort!.postMessage(response);\r\n\t} catch (err: any) {\r\n\t\t// Critical failure (transpiler setup / loader registration / registry extraction)\r\n\t\tconst response: LoaderWorkerResponse = {\r\n\t\t\ttype: 'ERROR',\r\n\t\t\terror: err.message || String(err),\r\n\t\t\tfileErrors: fileErrors.length > 0 ? fileErrors : undefined\r\n\t\t};\r\n\t\tparentPort!.postMessage(response);\r\n\t}\r\n}\r\n\r\n// Handle initial workerData (if files are passed at construction time)\r\nif (workerData && workerData.type === 'LOAD') {\r\n\tprocessMessage(workerData as LoaderWorkerRequest);\r\n}\r\n\r\n// Handle messages posted after construction\r\nparentPort?.on('message', (msg: LoaderWorkerRequest) => processMessage(msg));\r\n"]}
|
|
@@ -64,6 +64,7 @@ async function parallelPreload(options) {
|
|
|
64
64
|
const allDescriptors = [];
|
|
65
65
|
const allFiles = new Set();
|
|
66
66
|
let errors = 0;
|
|
67
|
+
let fileWarnings = 0;
|
|
67
68
|
for (const result of results) {
|
|
68
69
|
if (result.status === 'fulfilled') {
|
|
69
70
|
const response = result.value;
|
|
@@ -74,10 +75,22 @@ async function parallelPreload(options) {
|
|
|
74
75
|
if (response.loadedFiles) {
|
|
75
76
|
response.loadedFiles.forEach(f => allFiles.add(f));
|
|
76
77
|
}
|
|
78
|
+
// Per-file errors are non-fatal — the file just didn't contribute to the cache
|
|
79
|
+
if (response.fileErrors && response.fileErrors.length > 0) {
|
|
80
|
+
fileWarnings += response.fileErrors.length;
|
|
81
|
+
for (const fe of response.fileErrors) {
|
|
82
|
+
logger.checkpoint('File skipped during preload', { detail: fe });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
77
85
|
}
|
|
78
86
|
else {
|
|
79
87
|
errors++;
|
|
80
88
|
logger.error('Worker reported error', new Error(response.error || 'Unknown worker error'));
|
|
89
|
+
if (response.fileErrors) {
|
|
90
|
+
for (const fe of response.fileErrors) {
|
|
91
|
+
logger.checkpoint('File skipped during preload', { detail: fe });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
81
94
|
}
|
|
82
95
|
}
|
|
83
96
|
else {
|
|
@@ -90,11 +103,15 @@ async function parallelPreload(options) {
|
|
|
90
103
|
durationMs,
|
|
91
104
|
descriptorCount: allDescriptors.length,
|
|
92
105
|
fileCount: allFiles.size,
|
|
93
|
-
errors
|
|
106
|
+
errors,
|
|
107
|
+
fileWarnings
|
|
94
108
|
});
|
|
95
109
|
if (errors > 0) {
|
|
96
110
|
logger.checkpoint('Some workers failed — main thread will do full load as fallback');
|
|
97
111
|
}
|
|
112
|
+
if (fileWarnings > 0) {
|
|
113
|
+
logger.checkpoint(`${fileWarnings} file(s) skipped during preload — these will be loaded by the main thread`);
|
|
114
|
+
}
|
|
98
115
|
return {
|
|
99
116
|
descriptors: allDescriptors,
|
|
100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M,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB;IAC3B,6DAA6D;IAC7D,MAAM,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAC5D,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["/**\r\n * parallel-loader.ts\r\n *\r\n * Orchestrates parallel pre-warming of transpiler caches using worker_threads.\r\n * Each worker loads a subset of support-code files, warming the transpiler's\r\n * on-disk cache. After all workers finish, the main thread performs the\r\n * authoritative load (which hits warm caches and runs much faster).\r\n *\r\n * The descriptors returned by workers are used for validation — the main\r\n * thread's BindingRegistry is the canonical source of truth.\r\n */\r\nimport { Worker } from 'node:worker_threads';\r\nimport { availableParallelism } from 'node:os';\r\nimport path from 'node:path';\r\nimport type { LoaderWorkerRequest, LoaderWorkerResponse } from './loader-worker';\r\nimport type { SerializableBindingDescriptor } from '../bindings/step-binding';\r\nimport { createLogger } from '../utils/tsflow-logger';\r\n\r\nconst logger = createLogger('parallel-loader');\r\n\r\nexport interface ParallelLoadOptions {\r\n\t/** Absolute require-paths for CJS support files */\r\n\trequirePaths: string[];\r\n\t/** Absolute import-paths for ESM support files */\r\n\timportPaths: string[];\r\n\t/** Modules to require before support code (transpiler hooks) */\r\n\trequireModules: string[];\r\n\t/** ESM loaders to register */\r\n\tloaders: string[];\r\n\t/** Whether experimental decorators are enabled */\r\n\texperimentalDecorators: boolean;\r\n\t/** Number of threads (true = auto, number = explicit) */\r\n\tthreadCount: boolean | number;\r\n}\r\n\r\nexport interface ParallelLoadResult {\r\n\t/** All descriptors collected across workers (for validation) */\r\n\tdescriptors: SerializableBindingDescriptor[];\r\n\t/** Unique source files loaded across all workers */\r\n\tloadedFiles: string[];\r\n\t/** Time spent in parallel phase (ms) */\r\n\tdurationMs: number;\r\n}\r\n\r\n/**\r\n * Pre-warm transpiler caches by loading support files in parallel worker threads.\r\n *\r\n * Each worker receives a subset of files, loads them (which triggers transpilation),\r\n * and returns serializable binding descriptors. The transpiler cache on disk is now\r\n * warm for the main thread's subsequent load.\r\n */\r\nexport async function parallelPreload(options: ParallelLoadOptions): Promise<ParallelLoadResult> {\r\n\tconst start = performance.now();\r\n\r\n\tconst threads = resolveThreadCount(options.threadCount);\r\n\tlogger.checkpoint('Starting parallel preload', {\r\n\t\tthreads,\r\n\t\trequirePaths: options.requirePaths.length,\r\n\t\timportPaths: options.importPaths.length\r\n\t});\r\n\r\n\t// Split files across workers — round-robin distribution\r\n\tconst requireChunks = chunkRoundRobin(options.requirePaths, threads);\r\n\tconst importChunks = chunkRoundRobin(options.importPaths, threads);\r\n\r\n\t// Resolve the worker script path (compiled JS in lib/)\r\n\tconst workerScript = resolveWorkerScript();\r\n\tlogger.checkpoint('Worker script resolved', { workerScript });\r\n\r\n\t// Launch workers\r\n\tconst workerPromises: Promise<LoaderWorkerResponse>[] = [];\r\n\r\n\tfor (let i = 0; i < threads; i++) {\r\n\t\t// Only launch a worker if it has files to process\r\n\t\tif (requireChunks[i].length === 0 && importChunks[i].length === 0) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconst request: LoaderWorkerRequest = {\r\n\t\t\ttype: 'LOAD',\r\n\t\t\trequirePaths: requireChunks[i],\r\n\t\t\timportPaths: importChunks[i],\r\n\t\t\trequireModules: options.requireModules,\r\n\t\t\tloaders: options.loaders,\r\n\t\t\texperimentalDecorators: options.experimentalDecorators\r\n\t\t};\r\n\r\n\t\tworkerPromises.push(runWorker(workerScript, request, i));\r\n\t}\r\n\r\n\t// Await all workers\r\n\tconst results = await Promise.allSettled(workerPromises);\r\n\r\n\t// Collect results\r\n\tconst allDescriptors: SerializableBindingDescriptor[] = [];\r\n\tconst allFiles = new Set<string>();\r\n\tlet errors = 0;\r\n\r\n\tfor (const result of results) {\r\n\t\tif (result.status === 'fulfilled') {\r\n\t\t\tconst response = result.value;\r\n\t\t\tif (response.type === 'LOADED') {\r\n\t\t\t\tif (response.descriptors) {\r\n\t\t\t\t\tallDescriptors.push(...response.descriptors);\r\n\t\t\t\t}\r\n\t\t\t\tif (response.loadedFiles) {\r\n\t\t\t\t\tresponse.loadedFiles.forEach(f => allFiles.add(f));\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\terrors++;\r\n\t\t\t\tlogger.error('Worker reported error', new Error(response.error || 'Unknown worker error'));\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\terrors++;\r\n\t\t\tlogger.error('Worker promise rejected', result.reason);\r\n\t\t}\r\n\t}\r\n\r\n\tconst durationMs = Math.round(performance.now() - start);\r\n\tlogger.checkpoint('Parallel preload completed', {\r\n\t\tdurationMs,\r\n\t\tdescriptorCount: allDescriptors.length,\r\n\t\tfileCount: allFiles.size,\r\n\t\terrors\r\n\t});\r\n\r\n\tif (errors > 0) {\r\n\t\tlogger.checkpoint('Some workers failed — main thread will do full load as fallback');\r\n\t}\r\n\r\n\treturn {\r\n\t\tdescriptors: allDescriptors,\r\n\t\tloadedFiles: Array.from(allFiles),\r\n\t\tdurationMs\r\n\t};\r\n}\r\n\r\n/**\r\n * Run a single loader-worker and return its response.\r\n */\r\nfunction runWorker(workerScript: string, request: LoaderWorkerRequest, index: number): Promise<LoaderWorkerResponse> {\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tconst worker = new Worker(workerScript, {\r\n\t\t\tworkerData: request\r\n\t\t});\r\n\r\n\t\tlet settled = false;\r\n\r\n\t\tworker.on('message', (msg: LoaderWorkerResponse) => {\r\n\t\t\tif (!settled) {\r\n\t\t\t\tsettled = true;\r\n\t\t\t\tlogger.checkpoint(`Worker ${index} completed`, { type: msg.type });\r\n\t\t\t\tworker.terminate();\r\n\t\t\t\tresolve(msg);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tworker.on('error', err => {\r\n\t\t\tif (!settled) {\r\n\t\t\t\tsettled = true;\r\n\t\t\t\tlogger.error(`Worker ${index} error`, err);\r\n\t\t\t\treject(err);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tworker.on('exit', code => {\r\n\t\t\tif (!settled) {\r\n\t\t\t\tsettled = true;\r\n\t\t\t\tif (code !== 0) {\r\n\t\t\t\t\treject(new Error(`Worker ${index} exited with code ${code}`));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n}\r\n\r\n/**\r\n * Resolve the number of threads to use.\r\n * - true: use availableParallelism() capped at 4\r\n * - number: use that exact count (min 1)\r\n */\r\nfunction resolveThreadCount(threadCount: boolean | number): number {\r\n\tif (typeof threadCount === 'number') {\r\n\t\treturn Math.max(1, threadCount);\r\n\t}\r\n\t// Auto-detect: use available parallelism, capped at a reasonable default\r\n\treturn Math.min(availableParallelism(), 4);\r\n}\r\n\r\n/**\r\n * Distribute items round-robin across N buckets.\r\n */\r\nfunction chunkRoundRobin<T>(items: T[], buckets: number): T[][] {\r\n\tconst chunks: T[][] = Array.from({ length: buckets }, (): T[] => []);\r\n\tfor (let i = 0; i < items.length; i++) {\r\n\t\tchunks[i % buckets].push(items[i]);\r\n\t}\r\n\treturn chunks;\r\n}\r\n\r\n/**\r\n * Resolve the path to the compiled loader-worker script.\r\n * In development (src), this file is adjacent; in production (lib/), it's compiled.\r\n */\r\nfunction resolveWorkerScript(): string {\r\n\t// Try the compiled lib path first, falling back to __dirname\r\n\tconst libPath = path.resolve(__dirname, 'loader-worker.js');\r\n\treturn libPath;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"parallel-loader.js","sourceRoot":"","sources":["../../src/api/parallel-loader.ts"],"names":[],"mappings":";;;;;AAmDA,0CAqGC;AAxJD;;;;;;;;;;GAUG;AACH,6DAA6C;AAC7C,qCAA+C;AAC/C,0DAA6B;AAG7B,0DAAsD;AAEtD,MAAM,MAAM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AAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IACjC,CAAC;IACD,yEAAyE;IACzE,OAAO,IAAI,CAAC,GAAG,CAAC,IAAA,8BAAoB,GAAE,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAI,KAAU,EAAE,OAAe;IACtD,MAAM,MAAM,GAAU,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IACrE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB;IAC3B,6DAA6D;IAC7D,MAAM,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAC5D,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["/**\r\n * parallel-loader.ts\r\n *\r\n * Orchestrates parallel pre-warming of transpiler caches using worker_threads.\r\n * Each worker loads a subset of support-code files, warming the transpiler's\r\n * on-disk cache. After all workers finish, the main thread performs the\r\n * authoritative load (which hits warm caches and runs much faster).\r\n *\r\n * The descriptors returned by workers are used for validation — the main\r\n * thread's BindingRegistry is the canonical source of truth.\r\n */\r\nimport { Worker } from 'node:worker_threads';\r\nimport { availableParallelism } from 'node:os';\r\nimport path from 'node:path';\r\nimport type { LoaderWorkerRequest, LoaderWorkerResponse } from './loader-worker';\r\nimport type { SerializableBindingDescriptor } from '../bindings/step-binding';\r\nimport { createLogger } from '../utils/tsflow-logger';\r\n\r\nconst logger = createLogger('parallel-loader');\r\n\r\nexport interface ParallelLoadOptions {\r\n\t/** Absolute require-paths for CJS support files */\r\n\trequirePaths: string[];\r\n\t/** Absolute import-paths for ESM support files */\r\n\timportPaths: string[];\r\n\t/** Modules to require before support code (transpiler hooks) */\r\n\trequireModules: string[];\r\n\t/** ESM loaders to register */\r\n\tloaders: string[];\r\n\t/** Whether experimental decorators are enabled */\r\n\texperimentalDecorators: boolean;\r\n\t/** Number of threads (true = auto, number = explicit) */\r\n\tthreadCount: boolean | number;\r\n}\r\n\r\nexport interface ParallelLoadResult {\r\n\t/** All descriptors collected across workers (for validation) */\r\n\tdescriptors: SerializableBindingDescriptor[];\r\n\t/** Unique source files loaded across all workers */\r\n\tloadedFiles: string[];\r\n\t/** Time spent in parallel phase (ms) */\r\n\tdurationMs: number;\r\n}\r\n\r\n/**\r\n * Pre-warm transpiler caches by loading support files in parallel worker threads.\r\n *\r\n * Each worker receives a subset of files, loads them (which triggers transpilation),\r\n * and returns serializable binding descriptors. The transpiler cache on disk is now\r\n * warm for the main thread's subsequent load.\r\n */\r\nexport async function parallelPreload(options: ParallelLoadOptions): Promise<ParallelLoadResult> {\r\n\tconst start = performance.now();\r\n\r\n\tconst threads = resolveThreadCount(options.threadCount);\r\n\tlogger.checkpoint('Starting parallel preload', {\r\n\t\tthreads,\r\n\t\trequirePaths: options.requirePaths.length,\r\n\t\timportPaths: options.importPaths.length\r\n\t});\r\n\r\n\t// Split files across workers — round-robin distribution\r\n\tconst requireChunks = chunkRoundRobin(options.requirePaths, threads);\r\n\tconst importChunks = chunkRoundRobin(options.importPaths, threads);\r\n\r\n\t// Resolve the worker script path (compiled JS in lib/)\r\n\tconst workerScript = resolveWorkerScript();\r\n\tlogger.checkpoint('Worker script resolved', { workerScript });\r\n\r\n\t// Launch workers\r\n\tconst workerPromises: Promise<LoaderWorkerResponse>[] = [];\r\n\r\n\tfor (let i = 0; i < threads; i++) {\r\n\t\t// Only launch a worker if it has files to process\r\n\t\tif (requireChunks[i].length === 0 && importChunks[i].length === 0) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\r\n\t\tconst request: LoaderWorkerRequest = {\r\n\t\t\ttype: 'LOAD',\r\n\t\t\trequirePaths: requireChunks[i],\r\n\t\t\timportPaths: importChunks[i],\r\n\t\t\trequireModules: options.requireModules,\r\n\t\t\tloaders: options.loaders,\r\n\t\t\texperimentalDecorators: options.experimentalDecorators\r\n\t\t};\r\n\r\n\t\tworkerPromises.push(runWorker(workerScript, request, i));\r\n\t}\r\n\r\n\t// Await all workers\r\n\tconst results = await Promise.allSettled(workerPromises);\r\n\r\n\t// Collect results\r\n\tconst allDescriptors: SerializableBindingDescriptor[] = [];\r\n\tconst allFiles = new Set<string>();\r\n\tlet errors = 0;\r\n\tlet fileWarnings = 0;\r\n\r\n\tfor (const result of results) {\r\n\t\tif (result.status === 'fulfilled') {\r\n\t\t\tconst response = result.value;\r\n\t\t\tif (response.type === 'LOADED') {\r\n\t\t\t\tif (response.descriptors) {\r\n\t\t\t\t\tallDescriptors.push(...response.descriptors);\r\n\t\t\t\t}\r\n\t\t\t\tif (response.loadedFiles) {\r\n\t\t\t\t\tresponse.loadedFiles.forEach(f => allFiles.add(f));\r\n\t\t\t\t}\r\n\t\t\t\t// Per-file errors are non-fatal — the file just didn't contribute to the cache\r\n\t\t\t\tif (response.fileErrors && response.fileErrors.length > 0) {\r\n\t\t\t\t\tfileWarnings += response.fileErrors.length;\r\n\t\t\t\t\tfor (const fe of response.fileErrors) {\r\n\t\t\t\t\t\tlogger.checkpoint('File skipped during preload', { detail: fe });\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\terrors++;\r\n\t\t\t\tlogger.error('Worker reported error', new Error(response.error || 'Unknown worker error'));\r\n\t\t\t\tif (response.fileErrors) {\r\n\t\t\t\t\tfor (const fe of response.fileErrors) {\r\n\t\t\t\t\t\tlogger.checkpoint('File skipped during preload', { detail: fe });\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} else {\r\n\t\t\terrors++;\r\n\t\t\tlogger.error('Worker promise rejected', result.reason);\r\n\t\t}\r\n\t}\r\n\r\n\tconst durationMs = Math.round(performance.now() - start);\r\n\tlogger.checkpoint('Parallel preload completed', {\r\n\t\tdurationMs,\r\n\t\tdescriptorCount: allDescriptors.length,\r\n\t\tfileCount: allFiles.size,\r\n\t\terrors,\r\n\t\tfileWarnings\r\n\t});\r\n\r\n\tif (errors > 0) {\r\n\t\tlogger.checkpoint('Some workers failed — main thread will do full load as fallback');\r\n\t}\r\n\tif (fileWarnings > 0) {\r\n\t\tlogger.checkpoint(`${fileWarnings} file(s) skipped during preload — these will be loaded by the main thread`);\r\n\t}\r\n\r\n\treturn {\r\n\t\tdescriptors: allDescriptors,\r\n\t\tloadedFiles: Array.from(allFiles),\r\n\t\tdurationMs\r\n\t};\r\n}\r\n\r\n/**\r\n * Run a single loader-worker and return its response.\r\n */\r\nfunction runWorker(workerScript: string, request: LoaderWorkerRequest, index: number): Promise<LoaderWorkerResponse> {\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tconst worker = new Worker(workerScript, {\r\n\t\t\tworkerData: request\r\n\t\t});\r\n\r\n\t\tlet settled = false;\r\n\r\n\t\tworker.on('message', (msg: LoaderWorkerResponse) => {\r\n\t\t\tif (!settled) {\r\n\t\t\t\tsettled = true;\r\n\t\t\t\tlogger.checkpoint(`Worker ${index} completed`, { type: msg.type });\r\n\t\t\t\tworker.terminate();\r\n\t\t\t\tresolve(msg);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tworker.on('error', err => {\r\n\t\t\tif (!settled) {\r\n\t\t\t\tsettled = true;\r\n\t\t\t\tlogger.error(`Worker ${index} error`, err);\r\n\t\t\t\treject(err);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tworker.on('exit', code => {\r\n\t\t\tif (!settled) {\r\n\t\t\t\tsettled = true;\r\n\t\t\t\tif (code !== 0) {\r\n\t\t\t\t\treject(new Error(`Worker ${index} exited with code ${code}`));\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\t});\r\n}\r\n\r\n/**\r\n * Resolve the number of threads to use.\r\n * - true: use availableParallelism() capped at 4\r\n * - number: use that exact count (min 1)\r\n */\r\nfunction resolveThreadCount(threadCount: boolean | number): number {\r\n\tif (typeof threadCount === 'number') {\r\n\t\treturn Math.max(1, threadCount);\r\n\t}\r\n\t// Auto-detect: use available parallelism, capped at a reasonable default\r\n\treturn Math.min(availableParallelism(), 4);\r\n}\r\n\r\n/**\r\n * Distribute items round-robin across N buckets.\r\n */\r\nfunction chunkRoundRobin<T>(items: T[], buckets: number): T[][] {\r\n\tconst chunks: T[][] = Array.from({ length: buckets }, (): T[] => []);\r\n\tfor (let i = 0; i < items.length; i++) {\r\n\t\tchunks[i % buckets].push(items[i]);\r\n\t}\r\n\treturn chunks;\r\n}\r\n\r\n/**\r\n * Resolve the path to the compiled loader-worker script.\r\n * In development (src), this file is adjacent; in production (lib/), it's compiled.\r\n */\r\nfunction resolveWorkerScript(): string {\r\n\t// Try the compiled lib path first, falling back to __dirname\r\n\tconst libPath = path.resolve(__dirname, 'loader-worker.js');\r\n\treturn libPath;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cucumber.js","sourceRoot":"","sources":["../../src/api/run-cucumber.ts"],"names":[],"mappings":";;;;;AA0CA,kCA2LC;AArOD,iDAAuE;AACvE,mCAAsC;AAEtC,sGAAiH;AAEjH,8DAAkE;AAElE,0DAAsD;AACtD,sEAA6E;AAC7E,uCAAkD;AAClD,oEAA4F;AAC5F,gEAAyE;AACzE,qFAA4D;AAC5D,wCAAqC;AACrC,gEAA8E;AAE9E,oCAAkC;AAClC,mEAA+D;AAE/D,qCAAkC;AAClC,kDAA0B;AAE1B,uDAAoD;AACpD,0DAAsD;AAEtD,MAAM,SAAS,GAAG,IAAA,4BAAY,EAAC,c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AAK,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QACjF,CAAC,CAAC,CAAC;QACH,MAAM,iBAAiB,EAAE,CAAC;QAC1B,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;QAC9B,OAAO;YACN,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,kBAAkB;SAC3B,CAAC;IACH,CAAC;IAED,IAAA,oDAAuB,EAAC;QACvB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;KACL,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,IAAA,0BAAW,EAAC;QACjC,WAAW;QACX,MAAM;QACN,gBAAgB;QAChB,cAAc,EAAE,eAAe;QAC/B,KAAK;QACL,kBAAkB;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,OAAO;KAC5B,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;IAC9B,MAAM,iBAAiB,EAAE,CAAC;IAE1B,OAAO;QACN,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC3B,CAAC;AACH,CAAC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages';\r\nimport { EventEmitter } from 'events';\r\nimport { EventDataCollector } from '@cucumber/cucumber/lib/formatter/helpers/index';\r\nimport { emitMetaMessage, emitSupportCodeMessages } from '@cucumber/cucumber/lib/api/emit_support_code_messages';\r\nimport { IRunOptions, IRunResult } from '@cucumber/cucumber/lib/api/types';\r\nimport { resolvePaths } from '@cucumber/cucumber/lib/paths/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport { makeRuntime } from '../runtime/make-runtime';\r\nimport { initializeFormatters } from '@cucumber/cucumber/lib/api/formatters';\r\nimport { getSupportCodeLibrary } from './support';\r\nimport { IRunEnvironment, makeEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nimport { getPicklesAndErrors } from '@cucumber/cucumber/lib/api/gherkin';\r\nimport MessageCollector from '../runtime/message-collector';\r\nimport { version } from '../version';\r\nimport { initializeForRunCucumber } from '@cucumber/cucumber/lib/api/plugins';\r\nimport { IFilterablePickle } from '@cucumber/cucumber/lib/filter/index';\r\nimport 'polyfill-symbol-metadata';\r\nimport { BindingRegistry } from '../bindings/binding-registry';\r\nimport { ITsFlowRunOptionsRuntime } from '../runtime/types';\r\nimport { Console } from 'console';\r\nimport ansis from 'ansis';\r\nimport { supportCodeLibraryBuilder } from '@cucumber/cucumber';\r\nimport { parallelPreload } from './parallel-loader';\r\nimport { createLogger } from '../utils/tsflow-logger';\r\n\r\nconst runLogger = createLogger('run-cucumber');\r\n\r\nexport interface ITsFlowRunOptions extends IRunOptions {\r\n\truntime: ITsFlowRunOptionsRuntime;\r\n}\r\n\r\n/**\r\n * Execute a Cucumber test run.\r\n *\r\n * Extended from cucumber.js so that we can use our own implementation\r\n * of makeRuntime\r\n *\r\n * @public\r\n * @param options - Configuration loaded from `loadConfiguration`.\r\n * @param environment - Project environment.\r\n * @param onMessage - Callback fired each time Cucumber emits a message.\r\n */\r\nexport async function runCucumber(\r\n\toptions: ITsFlowRunOptions,\r\n\tenvironment: IRunEnvironment = {},\r\n\tonMessage?: (message: Envelope) => void\r\n): Promise<IRunResult> {\r\n\tconst mergedEnvironment = makeEnvironment(environment);\r\n\tconst { cwd, stdout, stderr, env, logger } = mergedEnvironment;\r\n\r\n\tlogger.debug(`Running cucumber-tsflow ${version}\r\nWorking directory: ${cwd}\r\nRunning from: ${__dirname}\r\n`);\r\n\tconst consoleLogger = new Console(environment.stdout as any, environment.stderr);\r\n\tif (options.runtime.experimentalDecorators) {\r\n\t\tconsoleLogger.info(ansis.yellowBright('Using Experimental Decorators.'));\r\n\t}\r\n\tif (options.runtime.parallel > 0) {\r\n\t\tconsoleLogger.info(\r\n\t\t\tansis.cyanBright(`Running Cucumber-TsFlow in Parallel with ${options.runtime.parallel} worker(s).\\n`)\r\n\t\t);\r\n\t} else {\r\n\t\tconsoleLogger.info(ansis.cyanBright('Running Cucumber-TsFlow in Serial mode.\\n'));\r\n\t}\r\n\r\n\tconst newId = IdGenerator.uuid();\r\n\r\n\tconst supportCoordinates =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? options.support.originalCoordinates\r\n\t\t\t: Object.assign(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\trequireModules: [],\r\n\t\t\t\t\t\trequirePaths: [],\r\n\t\t\t\t\t\tloaders: [],\r\n\t\t\t\t\t\timportPaths: []\r\n\t\t\t\t\t},\r\n\t\t\t\t\toptions.support\r\n\t\t\t\t);\r\n\r\n\tconst pluginManager = await initializeForRunCucumber(\r\n\t\t{\r\n\t\t\t...options,\r\n\t\t\tsupport: supportCoordinates\r\n\t\t},\r\n\t\tmergedEnvironment\r\n\t);\r\n\r\n\tconst resolvedPaths = await resolvePaths(logger, cwd, options.sources, supportCoordinates);\r\n\tpluginManager.emit('paths:resolve', resolvedPaths);\r\n\tconst { sourcePaths, requirePaths, importPaths } = resolvedPaths;\r\n\r\n\t/**\r\n\t * The support code library contains all of the hook and step definitions.\r\n\t * These are loaded into the library when calling getSupportCodeLibrary,\r\n\t * which loads all of the step definitions using require or import.\r\n\t */\r\n\tlet supportCodeLibrary =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? (options.support as SupportCodeLibrary)\r\n\t\t\t: await (async () => {\r\n\t\t\t\t\t// Parallel preload phase: warm transpiler caches in worker threads\r\n\t\t\t\t\tif (options.runtime.parallelLoad) {\r\n\t\t\t\t\t\trunLogger.checkpoint('Running parallel preload phase');\r\n\t\t\t\t\t\tconsoleLogger.info(ansis.cyanBright('Pre-warming transpiler caches in parallel...\\n'));\r\n\t\t\t\t\t\ttry {\r\n\t\t\t\t\t\t\tconst result = await parallelPreload({\r\n\t\t\t\t\t\t\t\trequirePaths,\r\n\t\t\t\t\t\t\t\timportPaths,\r\n\t\t\t\t\t\t\t\trequireModules: supportCoordinates.requireModules,\r\n\t\t\t\t\t\t\t\tloaders: supportCoordinates.loaders,\r\n\t\t\t\t\t\t\t\texperimentalDecorators: options.runtime.experimentalDecorators,\r\n\t\t\t\t\t\t\t\tthreadCount: options.runtime.parallelLoad\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\trunLogger.checkpoint('Parallel preload completed', {\r\n\t\t\t\t\t\t\t\tdescriptors: result.descriptors.length,\r\n\t\t\t\t\t\t\t\tfiles: result.loadedFiles.length,\r\n\t\t\t\t\t\t\t\tdurationMs: result.durationMs\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\tconsoleLogger.info(\r\n\t\t\t\t\t\t\t\tansis.cyanBright(\r\n\t\t\t\t\t\t\t\t\t`Parallel preload completed in ${result.durationMs}ms ` +\r\n\t\t\t\t\t\t\t\t\t\t`(${result.loadedFiles.length} files, ${result.descriptors.length} bindings)\\n`\r\n\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t} catch (err: any) {\r\n\t\t\t\t\t\t\trunLogger.error('Parallel preload failed, falling back to serial load', err);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn getSupportCodeLibrary({\r\n\t\t\t\t\t\tlogger,\r\n\t\t\t\t\t\tcwd,\r\n\t\t\t\t\t\tnewId,\r\n\t\t\t\t\t\trequirePaths,\r\n\t\t\t\t\t\trequireModules: supportCoordinates.requireModules,\r\n\t\t\t\t\t\timportPaths,\r\n\t\t\t\t\t\tloaders: supportCoordinates.loaders\r\n\t\t\t\t\t});\r\n\t\t\t\t})();\r\n\r\n\t// Set support to the updated step and hook definitions\r\n\t// in the supportCodeLibrary. We also need to initialize originalCoordinates\r\n\t// to support parallel execution.\r\n\tsupportCodeLibrary = BindingRegistry.instance.updateSupportCodeLibrary(supportCodeLibrary);\r\n\tsupportCodeLibrary = { ...supportCodeLibrary, ...{ originalCoordinates: supportCoordinates } };\r\n\toptions.support = supportCodeLibrary;\r\n\r\n\tconst eventBroadcaster = new EventEmitter();\r\n\tif (onMessage) {\r\n\t\teventBroadcaster.on('envelope', onMessage);\r\n\t}\r\n\teventBroadcaster.on('envelope', value => pluginManager.emit('message', value));\r\n\r\n\t// create a global instance of the message collector and bind it\r\n\t// to the event broadcaster. This is used by cucumber and for tests\r\n\t// that are not running in parallel.\r\n\tglobal.messageCollector = new MessageCollector(eventBroadcaster);\r\n\r\n\t// cast the MessageCollector to an EventDataCollector\r\n\tconst eventDataCollector = global.messageCollector as unknown as EventDataCollector;\r\n\r\n\tlet formatterStreamError = false;\r\n\tconst cleanupFormatters = await initializeFormatters({\r\n\t\tenv,\r\n\t\tcwd,\r\n\t\tstdout,\r\n\t\tstderr,\r\n\t\tlogger,\r\n\t\tonStreamError: () => (formatterStreamError = true),\r\n\t\teventBroadcaster,\r\n\t\teventDataCollector: eventDataCollector,\r\n\t\tconfiguration: options.formats,\r\n\t\tsupportCodeLibrary,\r\n\t\tpluginManager\r\n\t});\r\n\tawait emitMetaMessage(eventBroadcaster, env);\r\n\r\n\tlet filteredPickles: ReadonlyArray<IFilterablePickle> = [];\r\n\tlet parseErrors: ParseError[] = [];\r\n\tif (sourcePaths.length > 0) {\r\n\t\tconst gherkinResult = await getPicklesAndErrors({\r\n\t\t\tnewId,\r\n\t\t\tcwd,\r\n\t\t\tsourcePaths,\r\n\t\t\tcoordinates: options.sources,\r\n\t\t\tonEnvelope: envelope => eventBroadcaster.emit('envelope', envelope)\r\n\t\t});\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:filter', gherkinResult.filterablePickles);\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:order', filteredPickles);\r\n\t\tparseErrors = gherkinResult.parseErrors;\r\n\t}\r\n\tif (parseErrors.length) {\r\n\t\tparseErrors.forEach(parseError => {\r\n\t\t\tlogger.error(`Parse error in \"${parseError.source.uri}\" ${parseError.message}`);\r\n\t\t});\r\n\t\tawait cleanupFormatters();\r\n\t\tawait pluginManager.cleanup();\r\n\t\treturn {\r\n\t\t\tsuccess: false,\r\n\t\t\tsupport: supportCodeLibrary\r\n\t\t};\r\n\t}\r\n\r\n\temitSupportCodeMessages({\r\n\t\teventBroadcaster,\r\n\t\tsupportCodeLibrary,\r\n\t\tnewId\r\n\t});\r\n\r\n\tconst runtime = await makeRuntime({\r\n\t\tenvironment,\r\n\t\tlogger,\r\n\t\teventBroadcaster,\r\n\t\tsourcedPickles: filteredPickles,\r\n\t\tnewId,\r\n\t\tsupportCodeLibrary,\r\n\t\toptions: options.runtime,\r\n\t\tcoordinates: options.sources\r\n\t});\r\n\tconst success = await runtime.run();\r\n\tawait pluginManager.cleanup();\r\n\tawait cleanupFormatters();\r\n\r\n\treturn {\r\n\t\tsuccess: success && !formatterStreamError,\r\n\t\tsupport: supportCodeLibrary\r\n\t};\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"run-cucumber.js","sourceRoot":"","sources":["../../src/api/run-cucumber.ts"],"names":[],"mappings":";;;;;AAyCA,kCA2LC;AApOD,iDAAuE;AACvE,mCAAsC;AAEtC,sGAAiH;AAEjH,8DAAkE;AAElE,0DAAsD;AACtD,sEAA6E;AAC7E,uCAAkD;AAClD,oEAA4F;AAC5F,gEAAyE;AACzE,qFAA4D;AAC5D,wCAAqC;AACrC,gEAA8E;AAE9E,oCAAkC;AAClC,mEAA+D;AAE/D,qCAAkC;AAClC,kDAA0B;AAC1B,uDAAoD;AACpD,0DAAsD;AAEtD,MAAM,SAAS,GAAG,IAAA,4BAAY,EAAC,cAAc,CAAC,CAAC;AAM/C;;;;;;;;;;GAUG;AACI,KAAK,UAAU,WAAW,CAChC,OAA0B,EAC1B,cAA+B,EAAE,EACjC,SAAuC;IAEvC,MAAM,iBAAiB,GAAG,IAAA,uBAAe,EAAC,WAAW,CAAC,CAAC;IACvD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GA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AA,oDAAuB,EAAC;QACvB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;KACL,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,IAAA,0BAAW,EAAC;QACjC,WAAW;QACX,MAAM;QACN,gBAAgB;QAChB,cAAc,EAAE,eAAe;QAC/B,KAAK;QACL,kBAAkB;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,OAAO,CAAC,OAAO;KAC5B,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC;IAC9B,MAAM,iBAAiB,EAAE,CAAC;IAE1B,OAAO;QACN,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC3B,CAAC;AACH,CAAC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages';\r\nimport { EventEmitter } from 'events';\r\nimport { EventDataCollector } from '@cucumber/cucumber/lib/formatter/helpers/index';\r\nimport { emitMetaMessage, emitSupportCodeMessages } from '@cucumber/cucumber/lib/api/emit_support_code_messages';\r\nimport { IRunOptions, IRunResult } from '@cucumber/cucumber/lib/api/types';\r\nimport { resolvePaths } from '@cucumber/cucumber/lib/paths/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport { makeRuntime } from '../runtime/make-runtime';\r\nimport { initializeFormatters } from '@cucumber/cucumber/lib/api/formatters';\r\nimport { getSupportCodeLibrary } from './support';\r\nimport { IRunEnvironment, makeEnvironment } from '@cucumber/cucumber/lib/environment/index';\r\nimport { getPicklesAndErrors } from '@cucumber/cucumber/lib/api/gherkin';\r\nimport MessageCollector from '../runtime/message-collector';\r\nimport { version } from '../version';\r\nimport { initializeForRunCucumber } from '@cucumber/cucumber/lib/api/plugins';\r\nimport { IFilterablePickle } from '@cucumber/cucumber/lib/filter/index';\r\nimport 'polyfill-symbol-metadata';\r\nimport { BindingRegistry } from '../bindings/binding-registry';\r\nimport { ITsFlowRunOptionsRuntime } from '../runtime/types';\r\nimport { Console } from 'console';\r\nimport ansis from 'ansis';\r\nimport { parallelPreload } from './parallel-loader';\r\nimport { createLogger } from '../utils/tsflow-logger';\r\n\r\nconst runLogger = createLogger('run-cucumber');\r\n\r\nexport interface ITsFlowRunOptions extends IRunOptions {\r\n\truntime: ITsFlowRunOptionsRuntime;\r\n}\r\n\r\n/**\r\n * Execute a Cucumber test run.\r\n *\r\n * Extended from cucumber.js so that we can use our own implementation\r\n * of makeRuntime\r\n *\r\n * @public\r\n * @param options - Configuration loaded from `loadConfiguration`.\r\n * @param environment - Project environment.\r\n * @param onMessage - Callback fired each time Cucumber emits a message.\r\n */\r\nexport async function runCucumber(\r\n\toptions: ITsFlowRunOptions,\r\n\tenvironment: IRunEnvironment = {},\r\n\tonMessage?: (message: Envelope) => void\r\n): Promise<IRunResult> {\r\n\tconst mergedEnvironment = makeEnvironment(environment);\r\n\tconst { cwd, stdout, stderr, env, logger } = mergedEnvironment;\r\n\r\n\tlogger.debug(`Running cucumber-tsflow ${version}\r\nWorking directory: ${cwd}\r\nRunning from: ${__dirname}\r\n`);\r\n\tconst consoleLogger = new Console(environment.stdout as any, environment.stderr);\r\n\tif (options.runtime.experimentalDecorators) {\r\n\t\tconsoleLogger.info(ansis.yellowBright('Using Experimental Decorators.'));\r\n\t}\r\n\tif (options.runtime.parallel > 0) {\r\n\t\tconsoleLogger.info(\r\n\t\t\tansis.cyanBright(`Running Cucumber-TsFlow in Parallel with ${options.runtime.parallel} worker(s).\\n`)\r\n\t\t);\r\n\t} else {\r\n\t\tconsoleLogger.info(ansis.cyanBright('Running Cucumber-TsFlow in Serial mode.\\n'));\r\n\t}\r\n\r\n\tconst newId = IdGenerator.uuid();\r\n\r\n\tconst supportCoordinates =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? options.support.originalCoordinates\r\n\t\t\t: Object.assign(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\trequireModules: [],\r\n\t\t\t\t\t\trequirePaths: [],\r\n\t\t\t\t\t\tloaders: [],\r\n\t\t\t\t\t\timportPaths: []\r\n\t\t\t\t\t},\r\n\t\t\t\t\toptions.support\r\n\t\t\t\t);\r\n\r\n\tconst pluginManager = await initializeForRunCucumber(\r\n\t\t{\r\n\t\t\t...options,\r\n\t\t\tsupport: supportCoordinates\r\n\t\t},\r\n\t\tmergedEnvironment\r\n\t);\r\n\r\n\tconst resolvedPaths = await resolvePaths(logger, cwd, options.sources, supportCoordinates);\r\n\tpluginManager.emit('paths:resolve', resolvedPaths);\r\n\tconst { sourcePaths, requirePaths, importPaths } = resolvedPaths;\r\n\r\n\t/**\r\n\t * The support code library contains all of the hook and step definitions.\r\n\t * These are loaded into the library when calling getSupportCodeLibrary,\r\n\t * which loads all of the step definitions using require or import.\r\n\t */\r\n\tlet supportCodeLibrary =\r\n\t\t'originalCoordinates' in options.support\r\n\t\t\t? (options.support as SupportCodeLibrary)\r\n\t\t\t: await (async () => {\r\n\t\t\t\t\t// Parallel preload phase: warm transpiler caches in worker threads\r\n\t\t\t\t\tif (options.runtime.parallelLoad) {\r\n\t\t\t\t\t\trunLogger.checkpoint('Running parallel preload phase');\r\n\t\t\t\t\t\tconsoleLogger.info(ansis.cyanBright('Pre-warming transpiler caches in parallel...\\n'));\r\n\t\t\t\t\t\ttry {\r\n\t\t\t\t\t\t\tconst result = await parallelPreload({\r\n\t\t\t\t\t\t\t\trequirePaths,\r\n\t\t\t\t\t\t\t\timportPaths,\r\n\t\t\t\t\t\t\t\trequireModules: supportCoordinates.requireModules,\r\n\t\t\t\t\t\t\t\tloaders: supportCoordinates.loaders,\r\n\t\t\t\t\t\t\t\texperimentalDecorators: options.runtime.experimentalDecorators,\r\n\t\t\t\t\t\t\t\tthreadCount: options.runtime.parallelLoad\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\trunLogger.checkpoint('Parallel preload completed', {\r\n\t\t\t\t\t\t\t\tdescriptors: result.descriptors.length,\r\n\t\t\t\t\t\t\t\tfiles: result.loadedFiles.length,\r\n\t\t\t\t\t\t\t\tdurationMs: result.durationMs\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\tconsoleLogger.info(\r\n\t\t\t\t\t\t\t\tansis.cyanBright(\r\n\t\t\t\t\t\t\t\t\t`Parallel preload completed in ${result.durationMs}ms ` +\r\n\t\t\t\t\t\t\t\t\t\t`(${result.loadedFiles.length} files, ${result.descriptors.length} bindings)\\n`\r\n\t\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t} catch (err: any) {\r\n\t\t\t\t\t\t\trunLogger.error('Parallel preload failed, falling back to serial load', err);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn getSupportCodeLibrary({\r\n\t\t\t\t\t\tlogger,\r\n\t\t\t\t\t\tcwd,\r\n\t\t\t\t\t\tnewId,\r\n\t\t\t\t\t\trequirePaths,\r\n\t\t\t\t\t\trequireModules: supportCoordinates.requireModules,\r\n\t\t\t\t\t\timportPaths,\r\n\t\t\t\t\t\tloaders: supportCoordinates.loaders\r\n\t\t\t\t\t});\r\n\t\t\t\t})();\r\n\r\n\t// Set support to the updated step and hook definitions\r\n\t// in the supportCodeLibrary. We also need to initialize originalCoordinates\r\n\t// to support parallel execution.\r\n\tsupportCodeLibrary = BindingRegistry.instance.updateSupportCodeLibrary(supportCodeLibrary);\r\n\tsupportCodeLibrary = { ...supportCodeLibrary, ...{ originalCoordinates: supportCoordinates } };\r\n\toptions.support = supportCodeLibrary;\r\n\r\n\tconst eventBroadcaster = new EventEmitter();\r\n\tif (onMessage) {\r\n\t\teventBroadcaster.on('envelope', onMessage);\r\n\t}\r\n\teventBroadcaster.on('envelope', value => pluginManager.emit('message', value));\r\n\r\n\t// create a global instance of the message collector and bind it\r\n\t// to the event broadcaster. This is used by cucumber and for tests\r\n\t// that are not running in parallel.\r\n\tglobal.messageCollector = new MessageCollector(eventBroadcaster);\r\n\r\n\t// cast the MessageCollector to an EventDataCollector\r\n\tconst eventDataCollector = global.messageCollector as unknown as EventDataCollector;\r\n\r\n\tlet formatterStreamError = false;\r\n\tconst cleanupFormatters = await initializeFormatters({\r\n\t\tenv,\r\n\t\tcwd,\r\n\t\tstdout,\r\n\t\tstderr,\r\n\t\tlogger,\r\n\t\tonStreamError: () => (formatterStreamError = true),\r\n\t\teventBroadcaster,\r\n\t\teventDataCollector: eventDataCollector,\r\n\t\tconfiguration: options.formats,\r\n\t\tsupportCodeLibrary,\r\n\t\tpluginManager\r\n\t});\r\n\tawait emitMetaMessage(eventBroadcaster, env);\r\n\r\n\tlet filteredPickles: ReadonlyArray<IFilterablePickle> = [];\r\n\tlet parseErrors: ParseError[] = [];\r\n\tif (sourcePaths.length > 0) {\r\n\t\tconst gherkinResult = await getPicklesAndErrors({\r\n\t\t\tnewId,\r\n\t\t\tcwd,\r\n\t\t\tsourcePaths,\r\n\t\t\tcoordinates: options.sources,\r\n\t\t\tonEnvelope: envelope => eventBroadcaster.emit('envelope', envelope)\r\n\t\t});\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:filter', gherkinResult.filterablePickles);\r\n\t\tfilteredPickles = await pluginManager.transform('pickles:order', filteredPickles);\r\n\t\tparseErrors = gherkinResult.parseErrors;\r\n\t}\r\n\tif (parseErrors.length) {\r\n\t\tparseErrors.forEach(parseError => {\r\n\t\t\tlogger.error(`Parse error in \"${parseError.source.uri}\" ${parseError.message}`);\r\n\t\t});\r\n\t\tawait cleanupFormatters();\r\n\t\tawait pluginManager.cleanup();\r\n\t\treturn {\r\n\t\t\tsuccess: false,\r\n\t\t\tsupport: supportCodeLibrary\r\n\t\t};\r\n\t}\r\n\r\n\temitSupportCodeMessages({\r\n\t\teventBroadcaster,\r\n\t\tsupportCodeLibrary,\r\n\t\tnewId\r\n\t});\r\n\r\n\tconst runtime = await makeRuntime({\r\n\t\tenvironment,\r\n\t\tlogger,\r\n\t\teventBroadcaster,\r\n\t\tsourcedPickles: filteredPickles,\r\n\t\tnewId,\r\n\t\tsupportCodeLibrary,\r\n\t\toptions: options.runtime,\r\n\t\tcoordinates: options.sources\r\n\t});\r\n\tconst success = await runtime.run();\r\n\tawait pluginManager.cleanup();\r\n\tawait cleanupFormatters();\r\n\r\n\treturn {\r\n\t\tsuccess: success && !formatterStreamError,\r\n\t\tsupport: supportCodeLibrary\r\n\t};\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-decorator.js","sourceRoot":"","sources":["../../src/bindings/binding-decorator.ts"],"names":[],"mappings":";;AAqCA,sEAEC;AAUD,0BA4DC;AA7GD,iDAW4B;AAC5B,uDAA8F;AAC9F,yDAAkE;AAClE,iDAA+D;AAQ/D;;;;;;;GAOG;AACH,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAAiC,CAAC;AAE1E;;;;GAIG;AACH,SAAgB,6BAA6B;IAC5C,wBAAwB,CAAC,KAAK,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,OAAO,CAAC,oBAAoC;IAC3D,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACnC,OAAO,CAAI,MAAmC,EAAE,EAAE;YACjD,MAAM,eAAe,GAAG,kCAAe,CAAC,QAAQ,CAAC;YACjD,eAAe,CAAC,4BAA4B,CAAC,MAAM,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAErF,qGAAqG;YACrG,gEAAgE;YAChE,4FAA4F;YAC5F,MAAM,WAAW,GAAkB,IAAA,oCAAkB,GAAE,CAAC;YACxD,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBACjC,+FAA+F;gBAC/F,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;oBAC9B,WAAW,CAAC,cAAc,GAAG,MAAM,CAAC;gBACrC,CAAC;qBAAM,CAAC;oBACP,WAAW,CAAC,cAAc,GAA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;YAC7B,MAAM;QACP,CAAC;QACD,KAAK,+BAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;YACjC,MAAM,OAAO,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;YACnG,IAAA,oBAAS,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACjC,MAAM;QACP,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import {\r\n\tAfter,\r\n\tAfterStep,\r\n\tAfterAll,\r\n\tBefore,\r\n\tBeforeStep,\r\n\tBeforeAll,\r\n\tGiven,\r\n\tThen,\r\n\tWhen,\r\n\tWorld\r\n} from '@cucumber/cucumber';\r\nimport { getStepBindings, getStepBindingsExp, getCollectedBindings } from './binding-context';\r\nimport { BindingRegistry, DEFAULT_TAG } from './binding-registry';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport { ContextType, StepPattern } from './types';\r\nimport { defineParameterType } from '../index';\r\n\r\ninterface WritableWorld extends World {\r\n\t[key: string]: any;\r\n}\r\n\r\n/**\r\n * A set of step patterns that have been registered with Cucumber.\r\n *\r\n * In order to support scoped (or tagged) step definitions, we must ensure that any step binding is\r\n * only registered with Cucumber once. The binding function for that step pattern then becomes\r\n * responsible for looking up and execuing the step binding based on the context that is in scope at\r\n * the point of invocation.\r\n */\r\nconst stepPatternRegistrations = new Map<StepPattern, StepBindingFlags>();\r\n\r\n/**\r\n * Clear the step pattern registration cache. Must be called whenever\r\n * `supportCodeLibraryBuilder.reset()` is used so that decorators\r\n * re-register definitions with the fresh builder instance.\r\n */\r\nexport function resetStepPatternRegistrations(): void {\r\n\tstepPatternRegistrations.clear();\r\n}\r\n\r\n/**\r\n * A class decorator that marks the associated class as a CucumberJS binding.\r\n *\r\n * @param requiredContextTypes An optional array of Types that will be created and passed into the created\r\n * object for each scenario.\r\n *\r\n * An instance of the decorated class will be created for each scenario.\r\n */\r\nexport function binding(requiredContextTypes?: ContextType[]): any {\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: { new (...args: any[]): T }) => {\r\n\t\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\t\t\tbindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);\r\n\r\n\t\t\t// the class decorator is called last when decorators on a type are initialized. All other decorators\r\n\t\t\t// are added to DecoratorContext.metadata before this is called.\r\n\t\t\t// This will get all those bindings and then clear metadata for the next type that's loaded.\r\n\t\t\tconst allBindings: StepBinding[] = getStepBindingsExp();\r\n\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t// For static methods, we need to set the classPrototype to the class itself, not the prototype\r\n\t\t\t\tif (stepBinding.stepIsStatic) {\r\n\t\t\t\t\tstepBinding.classPrototype = target;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t// Register with cucumber\r\n\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t});\r\n\t\t};\r\n\t} else {\r\n\t\treturn function classDecorator(target: Function, context: ClassDecoratorContext) {\r\n\t\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\t\t\tbindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);\r\n\r\n\t\t\t// the class decorator is called last when decorators on a type are initialized. All other decorators\r\n\t\t\t// are added to DecoratorContext.metadata before this is called.\r\n\t\t\t// This will get all those bindings and then clear metadata for the next type that's loaded.\r\n\t\t\tconst allBindings: StepBinding[] = getStepBindings(context);\r\n\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t// Set the class prototype and then register the binding with the prototype\r\n\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t// add the step binding to the binding registry\r\n\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t});\r\n\r\n\t\t\t// Process pending step bindings after class is decorated\r\n\t\t\tcontext.addInitializer(function () {\r\n\t\t\t\t// Get all the collected bindings\r\n\t\t\t\tconst allBindings = getCollectedBindings();\r\n\r\n\t\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t\t// Set the class prototype and register\r\n\t\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t\t// Register with cucumber - call the local addStepBinding function\r\n\t\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\r\n\t\t\treturn target;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * Common helper used to add StepBindings to the binding registry\r\n * @param stepBinding\r\n * @returns\r\n */\r\nfunction addStepBinding(stepBinding: StepBinding): void {\r\n\t// In loader-worker threads, skip Cucumber registration — we only need\r\n\t// the BindingRegistry populated for descriptor extraction.\r\n\tif (global.__LOADER_WORKER) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (stepBinding.bindingType & StepBindingFlags.StepDefinitions) {\r\n\t\tlet stepBindingFlags = stepPatternRegistrations.get(stepBinding.stepPattern.toString());\r\n\t\tif (stepBindingFlags === undefined) {\r\n\t\t\tstepBindingFlags = StepBindingFlags.none;\r\n\t\t}\r\n\t\tif (stepBindingFlags & stepBinding.bindingType) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tbindStepDefinition(stepBinding);\r\n\t\tstepPatternRegistrations.set(stepBinding.stepPattern.toString(), stepBindingFlags | stepBinding.bindingType);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.Hooks) {\r\n\t\tbindHook(stepBinding);\r\n\t}\r\n}\r\n\r\n/**\r\n * Binds a step definition to Cucumber.\r\n *\r\n * @param stepBinding The [[StepBinding]] that represents a 'given', 'when', or 'then' step definition.\r\n */\r\nfunction bindStepDefinition(stepBinding: StepBinding): void {\r\n\tconst stepFunction = function (this: WritableWorld): any {\r\n\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\r\n\t\tconst scenarioContext = global.messageCollector.getStepScenarioContext(stepBinding);\r\n\r\n\t\tif (scenarioContext) {\r\n\t\t\tconst matchingStepBindings = bindingRegistry.getStepBindings(\r\n\t\t\t\tstepBinding.stepPattern.toString(),\r\n\t\t\t\tscenarioContext.scenarioInfo.tags\r\n\t\t\t);\r\n\r\n\t\t\tif (matchingStepBindings.length > 1) {\r\n\t\t\t\tlet message = `Ambiguous step definitions for '${matchingStepBindings[0].stepPattern}':\\n`;\r\n\r\n\t\t\t\tmatchingStepBindings.forEach(matchingStepBinding => {\r\n\t\t\t\t\tmessage =\r\n\t\t\t\t\t\tmessage +\r\n\t\t\t\t\t\t`\\t\\t${String(matchingStepBinding.classPropertyKey)} (${matchingStepBinding.callsite.toString()})\\n`;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tthrow new Error(message);\r\n\t\t\t} else if (matchingStepBindings.length === 0) {\r\n\t\t\t\tthrow new Error(\r\n\t\t\t\t\t`Cannot find matched step definition for ${stepBinding.stepPattern.toString()} with tag ${\r\n\t\t\t\t\t\tscenarioContext.scenarioInfo.tags\r\n\t\t\t\t\t} in binding registry`\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tconst contextTypes = bindingRegistry.getContextTypesForClass(matchingStepBindings[0].classPrototype);\r\n\t\t\tconst bindingObject = scenarioContext.getOrActivateBindingClass(\r\n\t\t\t\tmatchingStepBindings[0].classPrototype,\r\n\t\t\t\tcontextTypes,\r\n\t\t\t\tthis\r\n\t\t\t);\r\n\t\t\tbindingObject._worldObj = this;\r\n\r\n\t\t\treturn (bindingObject[matchingStepBindings[0].classPropertyKey] as Function).apply(\r\n\t\t\t\tbindingObject,\r\n\t\t\t\targuments as any\r\n\t\t\t);\r\n\t\t} else {\r\n\t\t\tthrow new Error('Unable to find the Scenario Context for a Step!');\r\n\t\t}\r\n\t};\r\n\r\n\tObject.defineProperty(stepFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\r\n\t// initialize options used on all step bindings\r\n\tconst options = {\r\n\t\tcucumberKey: stepBinding.cucumberKey,\r\n\t\ttimeout: stepBinding.timeout,\r\n\t\twrapperOptions: stepBinding.wrapperOption\r\n\t};\r\n\t// call appropriate step\r\n\tif (stepBinding.bindingType & StepBindingFlags.given) {\r\n\t\tGiven(stepBinding.stepPattern, options, stepFunction);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.when) {\r\n\t\tWhen(stepBinding.stepPattern, options, stepFunction);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.then) {\r\n\t\tThen(stepBinding.stepPattern, options, stepFunction);\r\n\t}\r\n}\r\n\r\n/**\r\n * Binds a hook to Cucumber.\r\n *\r\n * @param stepBinding The [[StepBinding]] that represents a 'before', or 'after', step definition.\r\n */\r\nfunction bindHook(stepBinding: StepBinding): void {\r\n\tconst globalHookFunction = function (this: any): any {\r\n\t\t// Check if it's a static method\r\n\t\tif (stepBinding.stepIsStatic || !stepBinding.classPrototype[stepBinding.classPropertyKey]) {\r\n\t\t\tconst constructor = stepBinding.classPrototype.constructor;\r\n\r\n\t\t\tif (constructor && constructor[stepBinding.classPropertyKey]) {\r\n\t\t\t\treturn constructor[stepBinding.classPropertyKey].apply(constructor);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// For non-static methods\r\n\t\tif (stepBinding.classPrototype[stepBinding.classPropertyKey]) {\r\n\t\t\treturn stepBinding.classPrototype[stepBinding.classPropertyKey].apply(stepBinding.classPrototype);\r\n\t\t}\r\n\r\n\t\tthrow new Error(\r\n\t\t\t`Method ${String(stepBinding.classPropertyKey)} not found on class ${stepBinding.classPrototype?.constructor?.name}`\r\n\t\t);\r\n\t};\r\n\t// Main binding for all other hooks (before, after, beforeStep, afterStep)\r\n\tconst hookFunction = function (this: any, arg: any): any {\r\n\t\tconst scenarioContext = global.messageCollector.getHookScenarioContext(arg);\r\n\t\tif (scenarioContext) {\r\n\t\t\tconst contextTypes = BindingRegistry.instance.getContextTypesForClass(stepBinding.classPrototype);\r\n\t\t\tconst bindingObject = scenarioContext.getOrActivateBindingClass(stepBinding.classPrototype, contextTypes, this);\r\n\t\t\tbindingObject._worldObj = this;\r\n\t\t\treturn (bindingObject[stepBinding.classPropertyKey] as Function).apply(bindingObject, arguments as any);\r\n\t\t} else {\r\n\t\t\tthrow new Error('Unable to find the Scenario Context for Hook!');\r\n\t\t}\r\n\t};\r\n\t// length values need to be added to our binding functions.\r\n\t// These are used in cucumber to determine if the function is\r\n\t// a callback or promise.\r\n\tObject.defineProperty(globalHookFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\tObject.defineProperty(hookFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\r\n\tconst tags = stepBinding.tags === DEFAULT_TAG ? undefined : stepBinding.tags;\r\n\r\n\t// This binds the appropriate function above to the associated\r\n\t// cucumber step functions.\r\n\tswitch (stepBinding.bindingType) {\r\n\t\tcase StepBindingFlags.beforeAll: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, timeout: stepBinding.timeout };\r\n\t\t\tBeforeAll(options, globalHookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.before: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tBefore(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.beforeStep: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tBeforeStep(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.afterAll: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, timeout: stepBinding.timeout };\r\n\t\t\tAfterAll(options, globalHookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.after: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tAfter(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.afterStep: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tAfterStep(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"binding-decorator.js","sourceRoot":"","sources":["../../src/bindings/binding-decorator.ts"],"names":[],"mappings":";;AAoCA,sEAEC;AAUD,0BA4DC;AA5GD,iDAW4B;AAC5B,uDAA8F;AAC9F,yDAAkE;AAClE,iDAA+D;AAO/D;;;;;;;GAOG;AACH,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAAiC,CAAC;AAE1E;;;;GAIG;AACH,SAAgB,6BAA6B;IAC5C,wBAAwB,CAAC,KAAK,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,OAAO,CAAC,oBAAoC;IAC3D,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACnC,OAAO,CAAI,MAAmC,EAAE,EAAE;YACjD,MAAM,eAAe,GAAG,kCAAe,CAAC,QAAQ,CAAC;YACjD,eAAe,CAAC,4BAA4B,CAAC,MAAM,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAErF,qGAAqG;YACrG,gEAAgE;YAChE,4FAA4F;YAC5F,MAAM,WAAW,GAAkB,IAAA,oCAAkB,GAAE,CAAC;YACxD,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;gBACjC,+FAA+F;gBAC/F,IAAI,WAAW,CAAC,YAAY,EAAE,CAAC;oBAC9B,WAAW,CAAC,cAAc,GAAG,MAAM,CAAC;gBACrC,CAAC;qBAAM,CAAC;oBACP,WAAW,CAAC,cAAc,GAA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;YAC7B,MAAM;QACP,CAAC;QACD,KAAK,+BAAgB,CAAC,SAAS,CAAC,CAAC,CAAC;YACjC,MAAM,OAAO,GAAG,EAAE,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;YACnG,IAAA,oBAAS,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YACjC,MAAM;QACP,CAAC;IACF,CAAC;AACF,CAAC","sourcesContent":["import {\r\n\tAfter,\r\n\tAfterStep,\r\n\tAfterAll,\r\n\tBefore,\r\n\tBeforeStep,\r\n\tBeforeAll,\r\n\tGiven,\r\n\tThen,\r\n\tWhen,\r\n\tWorld\r\n} from '@cucumber/cucumber';\r\nimport { getStepBindings, getStepBindingsExp, getCollectedBindings } from './binding-context';\r\nimport { BindingRegistry, DEFAULT_TAG } from './binding-registry';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport { ContextType, StepPattern } from './types';\r\n\r\ninterface WritableWorld extends World {\r\n\t[key: string]: any;\r\n}\r\n\r\n/**\r\n * A set of step patterns that have been registered with Cucumber.\r\n *\r\n * In order to support scoped (or tagged) step definitions, we must ensure that any step binding is\r\n * only registered with Cucumber once. The binding function for that step pattern then becomes\r\n * responsible for looking up and execuing the step binding based on the context that is in scope at\r\n * the point of invocation.\r\n */\r\nconst stepPatternRegistrations = new Map<StepPattern, StepBindingFlags>();\r\n\r\n/**\r\n * Clear the step pattern registration cache. Must be called whenever\r\n * `supportCodeLibraryBuilder.reset()` is used so that decorators\r\n * re-register definitions with the fresh builder instance.\r\n */\r\nexport function resetStepPatternRegistrations(): void {\r\n\tstepPatternRegistrations.clear();\r\n}\r\n\r\n/**\r\n * A class decorator that marks the associated class as a CucumberJS binding.\r\n *\r\n * @param requiredContextTypes An optional array of Types that will be created and passed into the created\r\n * object for each scenario.\r\n *\r\n * An instance of the decorated class will be created for each scenario.\r\n */\r\nexport function binding(requiredContextTypes?: ContextType[]): any {\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: { new (...args: any[]): T }) => {\r\n\t\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\t\t\tbindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);\r\n\r\n\t\t\t// the class decorator is called last when decorators on a type are initialized. All other decorators\r\n\t\t\t// are added to DecoratorContext.metadata before this is called.\r\n\t\t\t// This will get all those bindings and then clear metadata for the next type that's loaded.\r\n\t\t\tconst allBindings: StepBinding[] = getStepBindingsExp();\r\n\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t// For static methods, we need to set the classPrototype to the class itself, not the prototype\r\n\t\t\t\tif (stepBinding.stepIsStatic) {\r\n\t\t\t\t\tstepBinding.classPrototype = target;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t// Register with cucumber\r\n\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t});\r\n\t\t};\r\n\t} else {\r\n\t\treturn function classDecorator(target: Function, context: ClassDecoratorContext) {\r\n\t\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\t\t\tbindingRegistry.registerContextTypesForClass(target.prototype, requiredContextTypes);\r\n\r\n\t\t\t// the class decorator is called last when decorators on a type are initialized. All other decorators\r\n\t\t\t// are added to DecoratorContext.metadata before this is called.\r\n\t\t\t// This will get all those bindings and then clear metadata for the next type that's loaded.\r\n\t\t\tconst allBindings: StepBinding[] = getStepBindings(context);\r\n\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t// Set the class prototype and then register the binding with the prototype\r\n\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t// add the step binding to the binding registry\r\n\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t});\r\n\r\n\t\t\t// Process pending step bindings after class is decorated\r\n\t\t\tcontext.addInitializer(function () {\r\n\t\t\t\t// Get all the collected bindings\r\n\t\t\t\tconst allBindings = getCollectedBindings();\r\n\r\n\t\t\t\tallBindings.forEach(stepBinding => {\r\n\t\t\t\t\t// Set the class prototype and register\r\n\t\t\t\t\tstepBinding.classPrototype = target.prototype;\r\n\t\t\t\t\tbindingRegistry.registerStepBinding(stepBinding);\r\n\r\n\t\t\t\t\t// Register with cucumber - call the local addStepBinding function\r\n\t\t\t\t\taddStepBinding(stepBinding);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\r\n\t\t\treturn target;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * Common helper used to add StepBindings to the binding registry\r\n * @param stepBinding\r\n * @returns\r\n */\r\nfunction addStepBinding(stepBinding: StepBinding): void {\r\n\t// In loader-worker threads, skip Cucumber registration — we only need\r\n\t// the BindingRegistry populated for descriptor extraction.\r\n\tif (global.__LOADER_WORKER) {\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (stepBinding.bindingType & StepBindingFlags.StepDefinitions) {\r\n\t\tlet stepBindingFlags = stepPatternRegistrations.get(stepBinding.stepPattern.toString());\r\n\t\tif (stepBindingFlags === undefined) {\r\n\t\t\tstepBindingFlags = StepBindingFlags.none;\r\n\t\t}\r\n\t\tif (stepBindingFlags & stepBinding.bindingType) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tbindStepDefinition(stepBinding);\r\n\t\tstepPatternRegistrations.set(stepBinding.stepPattern.toString(), stepBindingFlags | stepBinding.bindingType);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.Hooks) {\r\n\t\tbindHook(stepBinding);\r\n\t}\r\n}\r\n\r\n/**\r\n * Binds a step definition to Cucumber.\r\n *\r\n * @param stepBinding The [[StepBinding]] that represents a 'given', 'when', or 'then' step definition.\r\n */\r\nfunction bindStepDefinition(stepBinding: StepBinding): void {\r\n\tconst stepFunction = function (this: WritableWorld): any {\r\n\t\tconst bindingRegistry = BindingRegistry.instance;\r\n\r\n\t\tconst scenarioContext = global.messageCollector.getStepScenarioContext(stepBinding);\r\n\r\n\t\tif (scenarioContext) {\r\n\t\t\tconst matchingStepBindings = bindingRegistry.getStepBindings(\r\n\t\t\t\tstepBinding.stepPattern.toString(),\r\n\t\t\t\tscenarioContext.scenarioInfo.tags\r\n\t\t\t);\r\n\r\n\t\t\tif (matchingStepBindings.length > 1) {\r\n\t\t\t\tlet message = `Ambiguous step definitions for '${matchingStepBindings[0].stepPattern}':\\n`;\r\n\r\n\t\t\t\tmatchingStepBindings.forEach(matchingStepBinding => {\r\n\t\t\t\t\tmessage =\r\n\t\t\t\t\t\tmessage +\r\n\t\t\t\t\t\t`\\t\\t${String(matchingStepBinding.classPropertyKey)} (${matchingStepBinding.callsite.toString()})\\n`;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tthrow new Error(message);\r\n\t\t\t} else if (matchingStepBindings.length === 0) {\r\n\t\t\t\tthrow new Error(\r\n\t\t\t\t\t`Cannot find matched step definition for ${stepBinding.stepPattern.toString()} with tag ${\r\n\t\t\t\t\t\tscenarioContext.scenarioInfo.tags\r\n\t\t\t\t\t} in binding registry`\r\n\t\t\t\t);\r\n\t\t\t}\r\n\r\n\t\t\tconst contextTypes = bindingRegistry.getContextTypesForClass(matchingStepBindings[0].classPrototype);\r\n\t\t\tconst bindingObject = scenarioContext.getOrActivateBindingClass(\r\n\t\t\t\tmatchingStepBindings[0].classPrototype,\r\n\t\t\t\tcontextTypes,\r\n\t\t\t\tthis\r\n\t\t\t);\r\n\t\t\tbindingObject._worldObj = this;\r\n\r\n\t\t\treturn (bindingObject[matchingStepBindings[0].classPropertyKey] as Function).apply(\r\n\t\t\t\tbindingObject,\r\n\t\t\t\targuments as any\r\n\t\t\t);\r\n\t\t} else {\r\n\t\t\tthrow new Error('Unable to find the Scenario Context for a Step!');\r\n\t\t}\r\n\t};\r\n\r\n\tObject.defineProperty(stepFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\r\n\t// initialize options used on all step bindings\r\n\tconst options = {\r\n\t\tcucumberKey: stepBinding.cucumberKey,\r\n\t\ttimeout: stepBinding.timeout,\r\n\t\twrapperOptions: stepBinding.wrapperOption\r\n\t};\r\n\t// call appropriate step\r\n\tif (stepBinding.bindingType & StepBindingFlags.given) {\r\n\t\tGiven(stepBinding.stepPattern, options, stepFunction);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.when) {\r\n\t\tWhen(stepBinding.stepPattern, options, stepFunction);\r\n\t} else if (stepBinding.bindingType & StepBindingFlags.then) {\r\n\t\tThen(stepBinding.stepPattern, options, stepFunction);\r\n\t}\r\n}\r\n\r\n/**\r\n * Binds a hook to Cucumber.\r\n *\r\n * @param stepBinding The [[StepBinding]] that represents a 'before', or 'after', step definition.\r\n */\r\nfunction bindHook(stepBinding: StepBinding): void {\r\n\tconst globalHookFunction = function (this: any): any {\r\n\t\t// Check if it's a static method\r\n\t\tif (stepBinding.stepIsStatic || !stepBinding.classPrototype[stepBinding.classPropertyKey]) {\r\n\t\t\tconst constructor = stepBinding.classPrototype.constructor;\r\n\r\n\t\t\tif (constructor && constructor[stepBinding.classPropertyKey]) {\r\n\t\t\t\treturn constructor[stepBinding.classPropertyKey].apply(constructor);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// For non-static methods\r\n\t\tif (stepBinding.classPrototype[stepBinding.classPropertyKey]) {\r\n\t\t\treturn stepBinding.classPrototype[stepBinding.classPropertyKey].apply(stepBinding.classPrototype);\r\n\t\t}\r\n\r\n\t\tthrow new Error(\r\n\t\t\t`Method ${String(stepBinding.classPropertyKey)} not found on class ${stepBinding.classPrototype?.constructor?.name}`\r\n\t\t);\r\n\t};\r\n\t// Main binding for all other hooks (before, after, beforeStep, afterStep)\r\n\tconst hookFunction = function (this: any, arg: any): any {\r\n\t\tconst scenarioContext = global.messageCollector.getHookScenarioContext(arg);\r\n\t\tif (scenarioContext) {\r\n\t\t\tconst contextTypes = BindingRegistry.instance.getContextTypesForClass(stepBinding.classPrototype);\r\n\t\t\tconst bindingObject = scenarioContext.getOrActivateBindingClass(stepBinding.classPrototype, contextTypes, this);\r\n\t\t\tbindingObject._worldObj = this;\r\n\t\t\treturn (bindingObject[stepBinding.classPropertyKey] as Function).apply(bindingObject, arguments as any);\r\n\t\t} else {\r\n\t\t\tthrow new Error('Unable to find the Scenario Context for Hook!');\r\n\t\t}\r\n\t};\r\n\t// length values need to be added to our binding functions.\r\n\t// These are used in cucumber to determine if the function is\r\n\t// a callback or promise.\r\n\tObject.defineProperty(globalHookFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\tObject.defineProperty(hookFunction, 'length', {\r\n\t\tvalue: stepBinding.stepArgsLength\r\n\t});\r\n\r\n\tconst tags = stepBinding.tags === DEFAULT_TAG ? undefined : stepBinding.tags;\r\n\r\n\t// This binds the appropriate function above to the associated\r\n\t// cucumber step functions.\r\n\tswitch (stepBinding.bindingType) {\r\n\t\tcase StepBindingFlags.beforeAll: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, timeout: stepBinding.timeout };\r\n\t\t\tBeforeAll(options, globalHookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.before: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tBefore(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.beforeStep: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tBeforeStep(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.afterAll: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, timeout: stepBinding.timeout };\r\n\t\t\tAfterAll(options, globalHookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.after: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tAfter(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\tcase StepBindingFlags.afterStep: {\r\n\t\t\tconst options = { cucumberKey: stepBinding.cucumberKey, tags: tags, timeout: stepBinding.timeout };\r\n\t\t\tAfterStep(options, hookFunction);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-decorators.js","sourceRoot":"","sources":["../../src/bindings/step-decorators.ts"],"names":[],"mappings":";;;;;AAYA,sBA8CC;AASD,oBA+CC;AASD,oBA+CC;AA1KD,wDAAiD;AACjD,iDAA+D;AAC/D,4DAAmC;AACnC,uDAA0F;AAE1F;;;;;;GAMG;AACH,SAAgB,KAAK,CAAC,WAA4B,EAAE,GAAY,EAAE,OAAgB,EAAE,aAAmB;IACtG,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACnC,OAAO,CAAI,MAAW,EAAE,WAA4B,EAAE,UAAsC,EAAE,EAAE;YAC/F,MAAM,YAAY,GAAG,UAAU,EAAE,KAAK,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9D,MAAM,WAAW,GAAgB;gBAChC,WAAW,EAAE,WAAW;gBACxB,WAAW,EAAE,+BAAgB,CAAC,KAAK;gBACnC,cAAc,EAAE,MAAM;gBACtB,gBAAgB,EAAE,WAAW;gBAC7B,YAAY;gBACZ,YAAY,EAAE,KAAK;gBACnB,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc;gBACtE,IAAI,EAAE,GAAG;gBACT,OAAO,EAAE,OAAO;gBAChB,aAAa,EAAE,aAAa;gBAC5B,QAAQ,EAAE,QA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C;AACF,CAAC","sourcesContent":["import { Callsite } from '../utils/our-callsite';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport shortUuid from 'short-uuid';\r\nimport { addStepBinding, addStepBindingExp, collectStepBinding } from './binding-context';\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Given' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function given(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.given,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function givenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.given,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'When' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function when(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.when,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function whenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.when,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Then' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function then(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.then,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function thenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.then,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"step-decorators.js","sourceRoot":"","sources":["../../src/bindings/step-decorators.ts"],"names":[],"mappings":";;;;;AAYA,sBA8CC;AASD,oBA+CC;AASD,oBA+CC;AA1KD,wDAAiD;AACjD,iDAA+D;AAC/D,4DAAmC;AACnC,uDAA0E;AAE1E;;;;;;GAMG;AACH,SAAgB,KAAK,CAAC,WAA4B,EAAE,GAAY,EAAE,OAAgB,EAAE,aAAmB;IACtG,MAAM,QAAQ,GAAG,uBAAQ,CAAC,OAAO,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACnC,OAAO,CAAI,MAAW,EAAE,WAA4B,EAAE,UAAsC,EAAE,EAAE;YAC/F,MAAM,YAAY,GAAG,UAAU,EAAE,KAAK,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9D,MAAM,WAAW,GAAgB;gBAChC,WAAW,EAAE,WAAW;gBACxB,WAAW,EAAE,+BAAgB,CAAC,KAAK;gBACnC,cAAc,EAAE,MAAM;gBACtB,gBAAgB,EAAE,WAAW;gBAC7B,YAAY;gBACZ,YAAY,EAAE,KAAK;gBACnB,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CA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CAAC,GAAG,EAAE;aAC9B,CAAC;YAEF,IAAA,oCAAkB,EAAC,WAAW,CAAC,CAAC;YAEhC,OAAO;QACR,CAAC,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["import { Callsite } from '../utils/our-callsite';\r\nimport { StepBinding, StepBindingFlags } from './step-binding';\r\nimport shortUuid from 'short-uuid';\r\nimport { addStepBindingExp, collectStepBinding } from './binding-context';\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Given' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function given(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.given,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function givenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.given,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'When' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function when(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.when,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function whenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.when,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n\r\n/**\r\n * A method decorator that marks the associated function as a 'Then' step.\r\n *\r\n * @param stepPattern The regular expression that will be used to match steps.\r\n * @param tag An optional tag.\r\n * @param timeout An optional timeout.\r\n */\r\nexport function then(stepPattern: RegExp | string, tag?: string, timeout?: number, wrapperOption?: any): any {\r\n\tconst callsite = Callsite.capture();\r\n\r\n\tif (global.experimentalDecorators) {\r\n\t\treturn <T>(target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => {\r\n\t\t\tconst stepFunction = descriptor?.value || target[propertyKey];\r\n\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.then,\r\n\t\t\t\tclassPrototype: target,\r\n\t\t\t\tclassPropertyKey: propertyKey,\r\n\t\t\t\tstepFunction,\r\n\t\t\t\tstepIsStatic: false,\r\n\t\t\t\tstepArgsLength: stepFunction ? stepFunction.length : 0, // Safe access\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\t\t\taddStepBindingExp(stepBinding);\r\n\r\n\t\t\treturn descriptor;\r\n\t\t};\r\n\t} else {\r\n\t\treturn function thenDecorator(target: Function, context: ClassMethodDecoratorContext) {\r\n\t\t\tconst stepBinding: StepBinding = {\r\n\t\t\t\tstepPattern: stepPattern,\r\n\t\t\t\tbindingType: StepBindingFlags.then,\r\n\t\t\t\tclassPrototype: undefined,\r\n\t\t\t\tclassPropertyKey: context.name,\r\n\t\t\t\tstepFunction: target,\r\n\t\t\t\tstepIsStatic: context.static,\r\n\t\t\t\tstepArgsLength: target.length,\r\n\t\t\t\ttags: tag,\r\n\t\t\t\ttimeout: timeout,\r\n\t\t\t\twrapperOption: wrapperOption,\r\n\t\t\t\tcallsite: callsite,\r\n\t\t\t\tcucumberKey: shortUuid().new()\r\n\t\t\t};\r\n\r\n\t\t\tcollectStepBinding(stepBinding);\r\n\r\n\t\t\treturn;\r\n\t\t};\r\n\t}\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/runtime/worker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6DAA+C;AAI/C,0EAAgD;AAChD,oEAA8F;
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/runtime/worker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6DAA+C;AAI/C,0EAAgD;AAChD,oEAA8F;AAS9F,MAAa,MAAM;IAEA;IACA;IACA;IACA;IACA;IALlB,YACkB,QAA4B,EAC5B,gBAA8B,EAC9B,KAAwB,EACxB,OAAuB,EACvB,kBAAsC;QAJtC,aAAQ,GAAR,QAAQ,CAAoB;QAC5B,qBAAgB,GAAhB,gBAAgB,CAAc;QAC9B,UAAK,GAAL,KAAK,CAAmB;QACxB,YAAO,GAAP,OAAO,CAAgB;QACvB,uBAAkB,GAAlB,kBAAkB,CAAoB;IACrD,CAAC;IAEJ,KAAK,CAAC,iB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B,CAAC,MAAM;oBAC5C,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;oBAClC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,YAAY;oBACtC,SAAS,EAAE;wBACV,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,IAAI,IAAI,OAAO;wBACxC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,YAAY;qBACtC;iBACD;gBACD,KAAK;aACL,CAAC;QACH,CAAC;IACF,CAAC;CACD;AA7FD,wBA6FC","sourcesContent":["import { EventEmitter } from 'node:events';\r\nimport * as messages from '@cucumber/messages';\r\nimport { IdGenerator } from '@cucumber/messages';\r\nimport { AssembledTestCase } from '@cucumber/cucumber/lib/assemble/index';\r\nimport { SupportCodeLibrary } from '@cucumber/cucumber/lib/support_code_library_builder/types';\r\nimport TestCaseRunner from './test-case-runner';\r\nimport { retriesForPickle, shouldCauseFailure } from '@cucumber/cucumber/lib/runtime/helpers';\r\nimport { RuntimeOptions } from '@cucumber/cucumber/lib/runtime/index';\r\n\r\n/** Result of running a single test-run hook */\r\nexport interface RunHookResult {\r\n\tresult: messages.TestStepResult;\r\n\terror?: any;\r\n}\r\n\r\nexport class Worker {\r\n\tconstructor(\r\n\t\tprivate readonly workerId: string | undefined,\r\n\t\tprivate readonly eventBroadcaster: EventEmitter,\r\n\t\tprivate readonly newId: IdGenerator.NewId,\r\n\t\tprivate readonly options: RuntimeOptions,\r\n\t\tprivate readonly supportCodeLibrary: SupportCodeLibrary\r\n\t) {}\r\n\r\n\tasync runBeforeAllHooks(): Promise<RunHookResult[]> {\r\n\t\tconst results: RunHookResult[] = [];\r\n\t\tfor (const hookDefinition of this.supportCodeLibrary.beforeTestRunHookDefinitions) {\r\n\t\t\tconst result = await this.runTestRunHook(hookDefinition, 'a BeforeAll');\r\n\t\t\tresults.push(result);\r\n\t\t}\r\n\t\treturn results;\r\n\t}\r\n\r\n\tasync runTestCase({ gherkinDocument, pickle, testCase }: AssembledTestCase, failing: boolean): Promise<boolean> {\r\n\t\tconst testCaseRunner = new TestCaseRunner({\r\n\t\t\tworkerId: this.workerId,\r\n\t\t\teventBroadcaster: this.eventBroadcaster,\r\n\t\t\tnewId: this.newId,\r\n\t\t\tgherkinDocument,\r\n\t\t\tpickle,\r\n\t\t\ttestCase,\r\n\t\t\tretries: retriesForPickle(pickle, this.options),\r\n\t\t\tskip: this.options.dryRun || (this.options.failFast && failing),\r\n\t\t\tfilterStackTraces: this.options.filterStacktraces,\r\n\t\t\tsupportCodeLibrary: this.supportCodeLibrary,\r\n\t\t\tworldParameters: this.options.worldParameters\r\n\t\t});\r\n\r\n\t\tconst status = await testCaseRunner.run();\r\n\r\n\t\treturn !shouldCauseFailure(status, this.options);\r\n\t}\r\n\r\n\tasync runAfterAllHooks(): Promise<RunHookResult[]> {\r\n\t\tconst results: RunHookResult[] = [];\r\n\t\tconst hooks = this.supportCodeLibrary.afterTestRunHookDefinitions.slice(0).reverse();\r\n\t\tfor (const hookDefinition of hooks) {\r\n\t\t\tconst result = await this.runTestRunHook(hookDefinition, 'an AfterAll');\r\n\t\t\tresults.push(result);\r\n\t\t}\r\n\t\treturn results;\r\n\t}\r\n\r\n\t/**\r\n\t * Run a single test-run hook (BeforeAll/AfterAll).\r\n\t * Replicates the logic previously in makeRunTestRunHooks which was removed\r\n\t * from Cucumber 12.3+.\r\n\t */\r\n\tprivate async runTestRunHook(hookDefinition: any, name: string): Promise<RunHookResult> {\r\n\t\tif (this.options.dryRun) {\r\n\t\t\treturn {\r\n\t\t\t\tresult: {\r\n\t\t\t\t\tstatus: messages.TestStepResultStatus.SKIPPED,\r\n\t\t\t\t\tduration: { seconds: 0, nanos: 0 }\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t}\r\n\r\n\t\ttry {\r\n\t\t\tawait hookDefinition.code.apply(null, []);\r\n\t\t\treturn {\r\n\t\t\t\tresult: {\r\n\t\t\t\t\tstatus: messages.TestStepResultStatus.PASSED,\r\n\t\t\t\t\tduration: { seconds: 0, nanos: 0 }\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t} catch (error: any) {\r\n\t\t\tlet errorMessage = `${name} hook errored`;\r\n\t\t\tif (this.workerId) {\r\n\t\t\t\terrorMessage += ` on worker ${this.workerId}`;\r\n\t\t\t}\r\n\t\t\tconst location = `${hookDefinition.uri}:${hookDefinition.line}`;\r\n\t\t\terrorMessage += `, process exiting: ${location}`;\r\n\r\n\t\t\treturn {\r\n\t\t\t\tresult: {\r\n\t\t\t\t\tstatus: messages.TestStepResultStatus.FAILED,\r\n\t\t\t\t\tduration: { seconds: 0, nanos: 0 },\r\n\t\t\t\t\tmessage: error.message || errorMessage,\r\n\t\t\t\t\texception: {\r\n\t\t\t\t\t\ttype: error.constructor?.name || 'Error',\r\n\t\t\t\t\t\tmessage: error.message || errorMessage\r\n\t\t\t\t\t}\r\n\t\t\t\t},\r\n\t\t\t\terror\r\n\t\t\t};\r\n\t\t}\r\n\t}\r\n}\r\n"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "7.7.
|
|
1
|
+
export declare const version = "7.7.2";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '7.7.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,OAAO,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '7.7.2'\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynxwall/cucumber-tsflow",
|
|
3
3
|
"description": "Provides 'specflow' like bindings for CucumberJS 12.7.0 in TypeScript 5.9+.",
|
|
4
|
-
"version": "7.7.
|
|
4
|
+
"version": "7.7.2",
|
|
5
5
|
"author": "Lonnie Wall <lynxdev@lynxwall.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|