@step-forge/step-forge 0.0.21 → 0.0.22
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/RUNTIME.md +42 -12
- package/dist/{analyzer-DYfdoSIS.js → analyzer-byS8yRrY.js} +52 -24
- package/dist/analyzer-byS8yRrY.js.map +1 -0
- package/dist/analyzer-cli.js +1 -1
- package/dist/analyzer.d.ts +2 -0
- package/dist/analyzer.js +1 -1
- package/dist/cli.cjs +129 -74
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +129 -74
- package/dist/cli.js.map +1 -1
- package/dist/{hooks-Dar49TtT.d.ts → config-C7PCYgYy.d.cts} +65 -16
- package/dist/{hooks-Dar49TtT.d.cts → config-C7PCYgYy.d.ts} +65 -16
- package/dist/{engine-DPRxs6eC.js → engine-DPVLEHBi.js} +8 -26
- package/dist/engine-DPVLEHBi.js.map +1 -0
- package/dist/{engine-DWAIlwWp.cjs → engine-vqA-eL_T.cjs} +8 -26
- package/dist/engine-vqA-eL_T.cjs.map +1 -0
- package/dist/{gherkinParser-CHpkEwii.cjs → gherkinParser-BT40q_i3.cjs} +97 -2
- package/dist/gherkinParser-BT40q_i3.cjs.map +1 -0
- package/dist/{gherkinParser-CKARHgt4.js → gherkinParser-NcttZgN4.js} +74 -3
- package/dist/gherkinParser-NcttZgN4.js.map +1 -0
- package/dist/hooks-BDCMKeNq.js +71 -0
- package/dist/{hooks-CywugMQQ.js.map → hooks-BDCMKeNq.js.map} +1 -1
- package/dist/{hooks-CGYzwDOv.cjs → hooks-Be0cjULN.cjs} +20 -31
- package/dist/{hooks-CGYzwDOv.cjs.map → hooks-Be0cjULN.cjs.map} +1 -1
- package/dist/runtime.cjs +3 -3
- package/dist/runtime.d.cts +11 -48
- package/dist/runtime.d.ts +11 -48
- package/dist/runtime.js +3 -3
- package/dist/step-forge.cjs +65 -28
- package/dist/step-forge.cjs.map +1 -1
- package/dist/step-forge.d.cts +13 -4
- package/dist/step-forge.d.ts +13 -4
- package/dist/step-forge.js +65 -28
- package/dist/step-forge.js.map +1 -1
- package/package.json +2 -2
- package/dist/analyzer-DYfdoSIS.js.map +0 -1
- package/dist/engine-DPRxs6eC.js.map +0 -1
- package/dist/engine-DWAIlwWp.cjs.map +0 -1
- package/dist/gherkinParser-CHpkEwii.cjs.map +0 -1
- package/dist/gherkinParser-CKARHgt4.js.map +0 -1
- package/dist/hooks-CywugMQQ.js +0 -82
package/dist/hooks-CywugMQQ.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
//#region src/runtime/registry.ts
|
|
2
|
-
/**
|
|
3
|
-
* A collection of registered steps. Deliberately a plain instance (not a hidden
|
|
4
|
-
* module global) so tests and the Vitest plugin can create isolated registries.
|
|
5
|
-
* `globalRegistry` is the default sink that `.step()` writes to.
|
|
6
|
-
*/
|
|
7
|
-
var StepRegistry = class {
|
|
8
|
-
steps = [];
|
|
9
|
-
add(step) {
|
|
10
|
-
this.steps.push(step);
|
|
11
|
-
}
|
|
12
|
-
all() {
|
|
13
|
-
return this.steps;
|
|
14
|
-
}
|
|
15
|
-
clear() {
|
|
16
|
-
this.steps = [];
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const globalRegistry = new StepRegistry();
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/runtime/hooks.ts
|
|
22
|
-
/**
|
|
23
|
-
* Collection of registered hooks. Like {@link StepRegistry}, a plain instance
|
|
24
|
-
* (not a hidden global) so tests can isolate; `globalHookRegistry` is the
|
|
25
|
-
* default sink the public `beforeScenario`/`afterAll`/etc helpers write to.
|
|
26
|
-
*/
|
|
27
|
-
var HookRegistry = class {
|
|
28
|
-
hooks = [];
|
|
29
|
-
add(hook) {
|
|
30
|
-
this.hooks.push(hook);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Hooks for a scope+timing. `before` hooks run in registration order;
|
|
34
|
-
* `after` hooks run in reverse (LIFO), so teardown unwinds setup.
|
|
35
|
-
*/
|
|
36
|
-
for(scope, timing) {
|
|
37
|
-
const matching = this.hooks.filter((h) => h.scope === scope && h.timing === timing);
|
|
38
|
-
return timing === "after" ? matching.reverse() : matching;
|
|
39
|
-
}
|
|
40
|
-
clear() {
|
|
41
|
-
this.hooks = [];
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const globalHookRegistry = new HookRegistry();
|
|
45
|
-
/**
|
|
46
|
-
* Run every registered feature/global hook of a scope+timing in order. Used by
|
|
47
|
-
* the generated test modules (feature hooks). Throws if a hook throws, so the
|
|
48
|
-
* runner reports it against the enclosing boundary.
|
|
49
|
-
*/
|
|
50
|
-
async function runHooks(scope, timing, registry = globalHookRegistry) {
|
|
51
|
-
for (const hook of registry.for(scope, timing)) await hook.fn();
|
|
52
|
-
}
|
|
53
|
-
const GLOBAL_GUARD = Symbol.for("step-forge.globalHooksStarted");
|
|
54
|
-
/**
|
|
55
|
-
* Run global before-hooks once per worker, ahead of that worker's first
|
|
56
|
-
* scenario, and schedule global after-hooks for worker exit. Idempotent: every
|
|
57
|
-
* feature module calls this in a `beforeAll`, but only the first call in a given
|
|
58
|
-
* worker does anything.
|
|
59
|
-
*
|
|
60
|
-
* Semantics & caveats (the once-per-worker model):
|
|
61
|
-
* - Runs in the *same* realm as steps, so global setup may touch in-process
|
|
62
|
-
* state that steps later read.
|
|
63
|
-
* - "Once per worker", not strictly once per run — with multiple workers it runs
|
|
64
|
-
* in each. Size global setup to be worker-safe (e.g. a server per worker).
|
|
65
|
-
* - Teardown is best-effort: after-hooks start on the worker's `beforeExit` and
|
|
66
|
-
* are not awaited by the runner, so keep them fast/synchronous.
|
|
67
|
-
*/
|
|
68
|
-
async function ensureGlobalHooks(registry = globalHookRegistry) {
|
|
69
|
-
const store = globalThis;
|
|
70
|
-
if (store[GLOBAL_GUARD]) return;
|
|
71
|
-
store[GLOBAL_GUARD] = true;
|
|
72
|
-
for (const hook of registry.for("global", "before")) await hook.fn();
|
|
73
|
-
process.once("beforeExit", () => {
|
|
74
|
-
(async () => {
|
|
75
|
-
for (const hook of registry.for("global", "after")) await hook.fn();
|
|
76
|
-
})();
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
//#endregion
|
|
80
|
-
export { StepRegistry as a, runHooks as i, ensureGlobalHooks as n, globalRegistry as o, globalHookRegistry as r, HookRegistry as t };
|
|
81
|
-
|
|
82
|
-
//# sourceMappingURL=hooks-CywugMQQ.js.map
|