@glubean/sdk 0.2.0 → 0.2.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.
Files changed (104) hide show
  1. package/dist/configure/http.d.ts +25 -0
  2. package/dist/configure/http.d.ts.map +1 -0
  3. package/dist/configure/http.js +88 -0
  4. package/dist/configure/http.js.map +1 -0
  5. package/dist/configure/index.d.ts +78 -0
  6. package/dist/configure/index.d.ts.map +1 -0
  7. package/dist/configure/index.js +78 -0
  8. package/dist/configure/index.js.map +1 -0
  9. package/dist/configure/plugin.d.ts +23 -0
  10. package/dist/configure/plugin.d.ts.map +1 -0
  11. package/dist/configure/plugin.js +81 -0
  12. package/dist/configure/plugin.js.map +1 -0
  13. package/dist/configure/runtime.d.ts +24 -0
  14. package/dist/configure/runtime.d.ts.map +1 -0
  15. package/dist/configure/runtime.js +45 -0
  16. package/dist/configure/runtime.js.map +1 -0
  17. package/dist/configure/template.d.ts +22 -0
  18. package/dist/configure/template.d.ts.map +1 -0
  19. package/dist/configure/template.js +34 -0
  20. package/dist/configure/template.js.map +1 -0
  21. package/dist/configure/vars.d.ts +20 -0
  22. package/dist/configure/vars.d.ts.map +1 -0
  23. package/dist/configure/vars.js +48 -0
  24. package/dist/configure/vars.js.map +1 -0
  25. package/dist/configure.d.ts +2 -150
  26. package/dist/configure.d.ts.map +1 -1
  27. package/dist/configure.js +2 -562
  28. package/dist/configure.js.map +1 -1
  29. package/dist/contract-artifacts.d.ts +268 -0
  30. package/dist/contract-artifacts.d.ts.map +1 -0
  31. package/dist/contract-artifacts.js +402 -0
  32. package/dist/contract-artifacts.js.map +1 -0
  33. package/dist/contract-core.d.ts +33 -1
  34. package/dist/contract-core.d.ts.map +1 -1
  35. package/dist/contract-core.js +51 -2
  36. package/dist/contract-core.js.map +1 -1
  37. package/dist/contract-http/adapter.d.ts.map +1 -1
  38. package/dist/contract-http/adapter.js +22 -7
  39. package/dist/contract-http/adapter.js.map +1 -1
  40. package/dist/contract-http/factory.d.ts.map +1 -1
  41. package/dist/contract-http/factory.js +13 -14
  42. package/dist/contract-http/factory.js.map +1 -1
  43. package/dist/contract-http/index.d.ts +4 -3
  44. package/dist/contract-http/index.d.ts.map +1 -1
  45. package/dist/contract-http/index.js +4 -3
  46. package/dist/contract-http/index.js.map +1 -1
  47. package/dist/contract-http/openapi.d.ts +56 -7
  48. package/dist/contract-http/openapi.d.ts.map +1 -1
  49. package/dist/contract-http/openapi.js +371 -21
  50. package/dist/contract-http/openapi.js.map +1 -1
  51. package/dist/contract-http/types.d.ts +2 -13
  52. package/dist/contract-http/types.d.ts.map +1 -1
  53. package/dist/contract-types.d.ts +59 -10
  54. package/dist/contract-types.d.ts.map +1 -1
  55. package/dist/expect.d.ts +13 -0
  56. package/dist/expect.d.ts.map +1 -1
  57. package/dist/expect.js +18 -0
  58. package/dist/expect.js.map +1 -1
  59. package/dist/index.d.ts +61 -518
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +26 -835
  62. package/dist/index.js.map +1 -1
  63. package/dist/install-plugin.d.ts +94 -0
  64. package/dist/install-plugin.d.ts.map +1 -0
  65. package/dist/install-plugin.js +222 -0
  66. package/dist/install-plugin.js.map +1 -0
  67. package/dist/internal.d.ts +2 -0
  68. package/dist/internal.d.ts.map +1 -1
  69. package/dist/internal.js +6 -0
  70. package/dist/internal.js.map +1 -1
  71. package/dist/plugin.d.ts +45 -34
  72. package/dist/plugin.d.ts.map +1 -1
  73. package/dist/plugin.js +47 -34
  74. package/dist/plugin.js.map +1 -1
  75. package/dist/runtime-carrier.d.ts +142 -0
  76. package/dist/runtime-carrier.d.ts.map +1 -0
  77. package/dist/runtime-carrier.js +148 -0
  78. package/dist/runtime-carrier.js.map +1 -0
  79. package/dist/session.d.ts.map +1 -1
  80. package/dist/session.js +2 -1
  81. package/dist/session.js.map +1 -1
  82. package/dist/test/builder.d.ts +249 -0
  83. package/dist/test/builder.d.ts.map +1 -0
  84. package/dist/test/builder.js +265 -0
  85. package/dist/test/builder.js.map +1 -0
  86. package/dist/test/each-builder.d.ts +244 -0
  87. package/dist/test/each-builder.d.ts.map +1 -0
  88. package/dist/test/each-builder.js +268 -0
  89. package/dist/test/each-builder.js.map +1 -0
  90. package/dist/test/extend.d.ts +59 -0
  91. package/dist/test/extend.d.ts.map +1 -0
  92. package/dist/test/extend.js +111 -0
  93. package/dist/test/extend.js.map +1 -0
  94. package/dist/test/utils.d.ts +39 -0
  95. package/dist/test/utils.d.ts.map +1 -0
  96. package/dist/test/utils.js +91 -0
  97. package/dist/test/utils.js.map +1 -0
  98. package/dist/types.d.ts +89 -111
  99. package/dist/types.d.ts.map +1 -1
  100. package/package.json +1 -1
  101. package/dist/contract-http/markdown.d.ts +0 -10
  102. package/dist/contract-http/markdown.d.ts.map +0 -1
  103. package/dist/contract-http/markdown.js +0 -21
  104. package/dist/contract-http/markdown.js.map +0 -1
@@ -0,0 +1,244 @@
1
+ /**
2
+ * @module each-builder
3
+ *
4
+ * Data-driven builder for multi-step tests (`EachBuilder`).
5
+ *
6
+ * Entry point: `test.each(table)("id-$key")` (no callback) returns an `EachBuilder`.
7
+ * Same fluent API as `TestBuilder`, but each step/setup/teardown also receives
8
+ * the data row (`row`) as a third argument. One `Test` is generated per row.
9
+ * Also exports `EachStepFunction`, `EachSetupFunction`, `EachTeardownFunction` types.
10
+ */
11
+ import type { ExtensionFn, StepMeta, Test, TestContext, TestMeta } from "../types.js";
12
+ /**
13
+ * Step function for data-driven builder tests.
14
+ * Receives context, current state, and the data row for this test.
15
+ *
16
+ * @template S The state type passed between steps
17
+ * @template T The data row type
18
+ * @template Ctx The context type (defaults to TestContext)
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const stepFn: EachStepFunction<{ token: string }, { userId: number }> =
23
+ * async (ctx, state, row) => {
24
+ * const res = await ctx.http.get(`/users/${row.userId}`);
25
+ * ctx.assert(res.ok, `user ${row.userId} found`);
26
+ * return state; // pass state to next step
27
+ * };
28
+ * ```
29
+ */
30
+ export type EachStepFunction<S, T, Ctx extends TestContext = TestContext> = (ctx: Ctx, state: S, row: T) => Promise<S | void>;
31
+ /**
32
+ * Setup function for data-driven builder tests.
33
+ * Receives context and the data row, returns initial state.
34
+ *
35
+ * @template S The state type to return
36
+ * @template T The data row type
37
+ * @template Ctx The context type (defaults to TestContext)
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const setupFn: EachSetupFunction<{ api: HttpClient }, { env: string }> =
42
+ * async (ctx, row) => {
43
+ * const api = ctx.http.extend({ prefixUrl: row.env });
44
+ * return { api };
45
+ * };
46
+ * ```
47
+ */
48
+ export type EachSetupFunction<S, T, Ctx extends TestContext = TestContext> = (ctx: Ctx, row: T) => Promise<S>;
49
+ /**
50
+ * Teardown function for data-driven builder tests.
51
+ *
52
+ * @template S The state type received from setup
53
+ * @template T The data row type
54
+ * @template Ctx The context type (defaults to TestContext)
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const teardownFn: EachTeardownFunction<{ sessionId: string }, { userId: number }> =
59
+ * async (ctx, state, row) => {
60
+ * await ctx.http.delete(`/sessions/${state.sessionId}`);
61
+ * ctx.log(`cleaned up session for user ${row.userId}`);
62
+ * };
63
+ * ```
64
+ */
65
+ export type EachTeardownFunction<S, T, Ctx extends TestContext = TestContext> = (ctx: Ctx, state: S, row: T) => Promise<void>;
66
+ /**
67
+ * Builder for data-driven tests with multi-step workflow support.
68
+ *
69
+ * Created by `test.each(table)(idTemplate)` (without a callback).
70
+ * Provides the same fluent `.step()` / `.setup()` / `.teardown()` API
71
+ * as `TestBuilder`, but each step/setup/teardown also receives the
72
+ * data row for the current test.
73
+ *
74
+ * On finalization, creates one `Test` per row in the table, each with
75
+ * full step definitions visible in `glubean scan` metadata and dashboards.
76
+ *
77
+ * @template S The state type for multi-step tests
78
+ * @template T The data row type
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * export const userFlows = test.each([
83
+ * { userId: 1 },
84
+ * { userId: 2 },
85
+ * ])("user-flow-$userId")
86
+ * .step("fetch user", async (ctx, state, { userId }) => {
87
+ * const res = await ctx.http.get(`/users/${userId}`);
88
+ * ctx.assert(res.ok, "user exists");
89
+ * return { user: await res.json() };
90
+ * })
91
+ * .step("verify posts", async (ctx, { user }) => {
92
+ * const res = await ctx.http.get(`/users/${user.id}/posts`);
93
+ * ctx.assert(res.ok, "posts accessible");
94
+ * });
95
+ * ```
96
+ */
97
+ export declare class EachBuilder<S = unknown, T extends Record<string, unknown> = Record<string, unknown>, Ctx extends TestContext = TestContext> {
98
+ private _baseMeta;
99
+ private _table;
100
+ private _setup?;
101
+ private _teardown?;
102
+ private _steps;
103
+ private _built;
104
+ private _parallel;
105
+ _fixtures?: Record<string, ExtensionFn<any>>;
106
+ /**
107
+ * Marker property so the runner and scanner can detect EachBuilder exports.
108
+ */
109
+ readonly __glubean_type: "each-builder";
110
+ constructor(baseMeta: TestMeta, table: readonly T[], fixtures?: Record<string, ExtensionFn<any>>, parallel?: boolean);
111
+ /**
112
+ * Set additional metadata for all generated tests.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * test.each(table)("user-$userId")
117
+ * .meta({ tags: ["smoke"], timeout: 10000 })
118
+ * .step("fetch", async (ctx, state, row) => { ... });
119
+ * ```
120
+ */
121
+ meta(meta: Omit<TestMeta, "id">): EachBuilder<S, T, Ctx>;
122
+ /**
123
+ * Mark all generated tests from this data set as focused.
124
+ * If `skip` is also set, skipped tests are still excluded.
125
+ */
126
+ only(): EachBuilder<S, T, Ctx>;
127
+ /**
128
+ * Mark all generated tests from this data set as skipped.
129
+ * Skip takes precedence over `only` when both are present.
130
+ */
131
+ skip(): EachBuilder<S, T, Ctx>;
132
+ /**
133
+ * Set the setup function. Receives context and data row, returns state.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * test.each(table)("id-$key")
138
+ * .setup(async (ctx, row) => {
139
+ * const api = ctx.http.extend({ headers: { "X-User": row.userId } });
140
+ * return { api };
141
+ * })
142
+ * .step("use api", async (ctx, { api }) => { ... });
143
+ * ```
144
+ */
145
+ setup<NewS>(fn: (ctx: Ctx, row: T) => Promise<NewS>): EachBuilder<NewS, T, Ctx>;
146
+ /**
147
+ * Set the teardown function. Runs after all steps (even on failure).
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * test.each(table)("user-$userId")
152
+ * .setup(async (ctx, row) => ({ token: await login(ctx, row) }))
153
+ * .step("test", async (ctx, { token }) => { ... })
154
+ * .teardown(async (ctx, state, row) => {
155
+ * await ctx.http.post("/logout", { body: { token: state.token } });
156
+ * });
157
+ * ```
158
+ */
159
+ teardown(fn: (ctx: Ctx, state: S, row: T) => Promise<void>): EachBuilder<S, T, Ctx>;
160
+ /**
161
+ * Add a step that does not return state (void).
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * test.each(users)("user-$id")
166
+ * .step("verify", async (ctx, state, row) => {
167
+ * const res = await ctx.http.get(`/users/${row.id}`);
168
+ * ctx.expect(res.status).toBe(200);
169
+ * });
170
+ * ```
171
+ */
172
+ step(name: string, fn: (ctx: Ctx, state: S, row: T) => Promise<void>): EachBuilder<S, T, Ctx>;
173
+ /**
174
+ * Add a step that returns new state, replacing the current state type.
175
+ */
176
+ step<NewS>(name: string, fn: (ctx: Ctx, state: S, row: T) => Promise<NewS>): EachBuilder<NewS, T, Ctx>;
177
+ /**
178
+ * Add a step with options (void return).
179
+ */
180
+ step(name: string, options: Omit<StepMeta, "name">, fn: (ctx: Ctx, state: S, row: T) => Promise<void>): EachBuilder<S, T, Ctx>;
181
+ /**
182
+ * Add a step with options, returning new state.
183
+ */
184
+ step<NewS>(name: string, options: Omit<StepMeta, "name">, fn: (ctx: Ctx, state: S, row: T) => Promise<NewS>): EachBuilder<NewS, T, Ctx>;
185
+ /**
186
+ * Apply a builder transform function for step composition.
187
+ *
188
+ * Works the same as `TestBuilder.use()` — reusable step sequences
189
+ * are plain functions that take a builder and return a builder.
190
+ *
191
+ * @param fn Transform function that receives this builder and returns a (possibly re-typed) builder
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * const withVerify = (b: EachBuilder<{ id: string }, { userId: number }>) => b
196
+ * .step("verify", async (ctx, { id }, row) => {
197
+ * ctx.expect(id).toBeTruthy();
198
+ * });
199
+ *
200
+ * export const users = test.each(table)("user-$userId")
201
+ * .setup(async (ctx, row) => ({ id: String(row.userId) }))
202
+ * .use(withVerify);
203
+ * ```
204
+ */
205
+ use<NewS>(fn: (builder: EachBuilder<S, T, Ctx>) => EachBuilder<NewS, T, Ctx>): EachBuilder<NewS, T, Ctx>;
206
+ /**
207
+ * Apply a builder transform and tag all newly added steps with a group ID.
208
+ *
209
+ * Works the same as `TestBuilder.group()` — steps added by `fn` are marked
210
+ * with `group` metadata for visual grouping in reports.
211
+ *
212
+ * @param id Group identifier (displayed in reports as a section header)
213
+ * @param fn Transform function that adds steps to the builder
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * export const users = test.each(table)("user-$userId")
218
+ * .group("setup", b => b
219
+ * .step("init", async (ctx, state, row) => ({ id: String(row.userId) }))
220
+ * )
221
+ * .step("verify", async (ctx, { id }) => { ... });
222
+ * ```
223
+ */
224
+ group<NewS>(id: string, fn: (builder: EachBuilder<S, T, Ctx>) => EachBuilder<NewS, T, Ctx>): EachBuilder<NewS, T, Ctx>;
225
+ /** @internal */
226
+ private _filteredTable;
227
+ /** @internal */
228
+ private _tagsForRow;
229
+ /**
230
+ * Finalize and register all tests in the global registry.
231
+ * Called automatically via microtask if not explicitly invoked via build().
232
+ * Idempotent — safe to call multiple times.
233
+ * @internal
234
+ */
235
+ private _finalize;
236
+ /**
237
+ * Build and register all tests. Returns a `Test[]` array.
238
+ *
239
+ * **Optional** — if omitted, the builder auto-finalizes via microtask
240
+ * and the runner will auto-detect the EachBuilder export.
241
+ */
242
+ build(): Test<S>[];
243
+ }
244
+ //# sourceMappingURL=each-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"each-builder.d.ts","sourceRoot":"","sources":["../../src/test/each-builder.ts"],"names":[],"mappings":"AAAA;;;;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EAAE,GAAG,CAAC,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,GACjE,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC;IAS5B,gBAAgB;IAChB,OAAO,CAAC,cAAc;IAMtB,gBAAgB;IAChB,OAAO,CAAC,WAAW;IAYnB;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IA+BjB;;;;;OAKG;IACH,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE;CAiCnB"}
@@ -0,0 +1,268 @@
1
+ import { registerTest } from "../internal.js";
2
+ import { toArray } from "../data.js";
3
+ import { interpolateTemplate } from "./utils.js";
4
+ /**
5
+ * Builder for data-driven tests with multi-step workflow support.
6
+ *
7
+ * Created by `test.each(table)(idTemplate)` (without a callback).
8
+ * Provides the same fluent `.step()` / `.setup()` / `.teardown()` API
9
+ * as `TestBuilder`, but each step/setup/teardown also receives the
10
+ * data row for the current test.
11
+ *
12
+ * On finalization, creates one `Test` per row in the table, each with
13
+ * full step definitions visible in `glubean scan` metadata and dashboards.
14
+ *
15
+ * @template S The state type for multi-step tests
16
+ * @template T The data row type
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * export const userFlows = test.each([
21
+ * { userId: 1 },
22
+ * { userId: 2 },
23
+ * ])("user-flow-$userId")
24
+ * .step("fetch user", async (ctx, state, { userId }) => {
25
+ * const res = await ctx.http.get(`/users/${userId}`);
26
+ * ctx.assert(res.ok, "user exists");
27
+ * return { user: await res.json() };
28
+ * })
29
+ * .step("verify posts", async (ctx, { user }) => {
30
+ * const res = await ctx.http.get(`/users/${user.id}/posts`);
31
+ * ctx.assert(res.ok, "posts accessible");
32
+ * });
33
+ * ```
34
+ */
35
+ export class EachBuilder {
36
+ _baseMeta;
37
+ _table;
38
+ _setup;
39
+ _teardown;
40
+ _steps = [];
41
+ _built = false;
42
+ _parallel;
43
+ _fixtures;
44
+ /**
45
+ * Marker property so the runner and scanner can detect EachBuilder exports.
46
+ */
47
+ __glubean_type = "each-builder";
48
+ constructor(baseMeta, table, fixtures, parallel = false) {
49
+ this._baseMeta = baseMeta;
50
+ this._table = table;
51
+ this._fixtures = fixtures;
52
+ this._parallel = parallel;
53
+ // Auto-finalize after all synchronous chaining completes.
54
+ queueMicrotask(() => this._finalize());
55
+ }
56
+ /**
57
+ * Set additional metadata for all generated tests.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * test.each(table)("user-$userId")
62
+ * .meta({ tags: ["smoke"], timeout: 10000 })
63
+ * .step("fetch", async (ctx, state, row) => { ... });
64
+ * ```
65
+ */
66
+ meta(meta) {
67
+ this._baseMeta = { ...this._baseMeta, ...meta };
68
+ return this;
69
+ }
70
+ /**
71
+ * Mark all generated tests from this data set as focused.
72
+ * If `skip` is also set, skipped tests are still excluded.
73
+ */
74
+ only() {
75
+ this._baseMeta = { ...this._baseMeta, only: true };
76
+ return this;
77
+ }
78
+ /**
79
+ * Mark all generated tests from this data set as skipped.
80
+ * Skip takes precedence over `only` when both are present.
81
+ */
82
+ skip() {
83
+ this._baseMeta = { ...this._baseMeta, skip: true };
84
+ return this;
85
+ }
86
+ /**
87
+ * Set the setup function. Receives context and data row, returns state.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * test.each(table)("id-$key")
92
+ * .setup(async (ctx, row) => {
93
+ * const api = ctx.http.extend({ headers: { "X-User": row.userId } });
94
+ * return { api };
95
+ * })
96
+ * .step("use api", async (ctx, { api }) => { ... });
97
+ * ```
98
+ */
99
+ setup(fn) {
100
+ this._setup = fn;
101
+ return this;
102
+ }
103
+ /**
104
+ * Set the teardown function. Runs after all steps (even on failure).
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * test.each(table)("user-$userId")
109
+ * .setup(async (ctx, row) => ({ token: await login(ctx, row) }))
110
+ * .step("test", async (ctx, { token }) => { ... })
111
+ * .teardown(async (ctx, state, row) => {
112
+ * await ctx.http.post("/logout", { body: { token: state.token } });
113
+ * });
114
+ * ```
115
+ */
116
+ teardown(fn) {
117
+ this._teardown = fn;
118
+ return this;
119
+ }
120
+ step(name, optionsOrFn, maybeFn) {
121
+ const fn = typeof optionsOrFn === "function" ? optionsOrFn : maybeFn;
122
+ const options = typeof optionsOrFn === "function" ? {} : optionsOrFn;
123
+ this._steps.push({
124
+ meta: { name, ...options },
125
+ fn,
126
+ });
127
+ return this;
128
+ }
129
+ /**
130
+ * Apply a builder transform function for step composition.
131
+ *
132
+ * Works the same as `TestBuilder.use()` — reusable step sequences
133
+ * are plain functions that take a builder and return a builder.
134
+ *
135
+ * @param fn Transform function that receives this builder and returns a (possibly re-typed) builder
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const withVerify = (b: EachBuilder<{ id: string }, { userId: number }>) => b
140
+ * .step("verify", async (ctx, { id }, row) => {
141
+ * ctx.expect(id).toBeTruthy();
142
+ * });
143
+ *
144
+ * export const users = test.each(table)("user-$userId")
145
+ * .setup(async (ctx, row) => ({ id: String(row.userId) }))
146
+ * .use(withVerify);
147
+ * ```
148
+ */
149
+ use(fn) {
150
+ return fn(this);
151
+ }
152
+ /**
153
+ * Apply a builder transform and tag all newly added steps with a group ID.
154
+ *
155
+ * Works the same as `TestBuilder.group()` — steps added by `fn` are marked
156
+ * with `group` metadata for visual grouping in reports.
157
+ *
158
+ * @param id Group identifier (displayed in reports as a section header)
159
+ * @param fn Transform function that adds steps to the builder
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * export const users = test.each(table)("user-$userId")
164
+ * .group("setup", b => b
165
+ * .step("init", async (ctx, state, row) => ({ id: String(row.userId) }))
166
+ * )
167
+ * .step("verify", async (ctx, { id }) => { ... });
168
+ * ```
169
+ */
170
+ group(id, fn) {
171
+ const before = this._steps.length;
172
+ const result = fn(this);
173
+ for (let i = before; i < this._steps.length; i++) {
174
+ this._steps[i].meta.group = id;
175
+ }
176
+ return result;
177
+ }
178
+ /** @internal */
179
+ _filteredTable() {
180
+ const filter = this._baseMeta.filter;
181
+ if (!filter)
182
+ return this._table;
183
+ return this._table.filter((row, index) => filter(row, index));
184
+ }
185
+ /** @internal */
186
+ _tagsForRow(row) {
187
+ const staticTags = toArray(this._baseMeta.tags);
188
+ const tagFieldNames = toArray(this._baseMeta.tagFields);
189
+ const dynamicTags = tagFieldNames
190
+ .map((field) => {
191
+ const value = row[field];
192
+ return value != null ? `${field}:${value}` : null;
193
+ })
194
+ .filter((t) => t !== null);
195
+ return [...staticTags, ...dynamicTags];
196
+ }
197
+ /**
198
+ * Finalize and register all tests in the global registry.
199
+ * Called automatically via microtask if not explicitly invoked via build().
200
+ * Idempotent — safe to call multiple times.
201
+ * @internal
202
+ */
203
+ _finalize() {
204
+ if (this._built)
205
+ return;
206
+ this._built = true;
207
+ const stepMetas = this._steps.map((s) => ({
208
+ name: s.meta.name,
209
+ ...(s.meta.group ? { group: s.meta.group } : {}),
210
+ }));
211
+ const table = this._filteredTable();
212
+ const isPick = table.length > 0 && "_pick" in table[0];
213
+ const hasGroup = isPick || this._parallel;
214
+ for (let i = 0; i < table.length; i++) {
215
+ const row = table[i];
216
+ const id = interpolateTemplate(this._baseMeta.id, row, i);
217
+ const name = this._baseMeta.name ? interpolateTemplate(this._baseMeta.name, row, i) : id;
218
+ registerTest({
219
+ id,
220
+ name,
221
+ type: "steps",
222
+ tags: this._tagsForRow(row),
223
+ description: this._baseMeta.description,
224
+ steps: stepMetas,
225
+ hasSetup: !!this._setup,
226
+ hasTeardown: !!this._teardown,
227
+ ...(hasGroup ? { groupId: this._baseMeta.id } : {}),
228
+ ...(this._parallel ? { parallel: true } : {}),
229
+ });
230
+ }
231
+ }
232
+ /**
233
+ * Build and register all tests. Returns a `Test[]` array.
234
+ *
235
+ * **Optional** — if omitted, the builder auto-finalizes via microtask
236
+ * and the runner will auto-detect the EachBuilder export.
237
+ */
238
+ build() {
239
+ this._finalize();
240
+ const table = this._filteredTable();
241
+ return table.map((row, index) => {
242
+ const id = interpolateTemplate(this._baseMeta.id, row, index);
243
+ const name = this._baseMeta.name ? interpolateTemplate(this._baseMeta.name, row, index) : id;
244
+ const meta = {
245
+ ...this._baseMeta,
246
+ id,
247
+ name,
248
+ tags: this._tagsForRow(row),
249
+ };
250
+ const setup = this._setup;
251
+ const teardown = this._teardown;
252
+ return {
253
+ meta,
254
+ type: "steps",
255
+ setup: setup ? ((ctx) => setup(ctx, row)) : undefined,
256
+ teardown: teardown
257
+ ? ((ctx, state) => teardown(ctx, state, row))
258
+ : undefined,
259
+ steps: this._steps.map((s) => ({
260
+ meta: s.meta,
261
+ fn: ((ctx, state) => s.fn(ctx, state, row)),
262
+ })),
263
+ ...(this._fixtures ? { fixtures: this._fixtures } : {}),
264
+ };
265
+ });
266
+ }
267
+ }
268
+ //# sourceMappingURL=each-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"each-builder.js","sourceRoot":"","sources":["../../src/test/each-builder.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAsEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAO,WAAW;IAKd,SAAS,CAAW;IACpB,MAAM,CAAe;IACrB,MAAM,CAAgC;IACtC,SAAS,CAAmC;IAE5C,MAAM,GAA4D,EAAE,CAAC;IACrE,MAAM,GAAG,KAAK,CAAC;IACf,SAAS,CAAU;IAE3B,SAAS,CAAoC;IAE7C;;OAEG;IACM,cAAc,GAAG,cAAuB,CAAC;IAElD,YACE,QAAkB,EAClB,KAAmB,EACnB,QAA2C,EAC3C,QAAQ,GAAG,KAAK;QAEhB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;Q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AAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;aAC5B,CAAC;YAEF,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;YAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;YAEhC,OAAO;gBACL,IAAI;gBACJ,IAAI,EAAE,OAAgB;gBACtB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC,GAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,GAAU,EAAE,GAAG,CAAC,CAAsB,CAAC,CAAC,CAAC,SAAS;gBAC/F,QAAQ,EAAE,QAAQ;oBAChB,CAAC,CAAE,CAAC,CAAC,GAAgB,EAAE,KAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAU,EAAE,KAAK,EAAE,GAAG,CAAC,CAAyB;oBAC7F,CAAC,CAAC,SAAS;gBACb,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAC7B,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,EAAE,EAAE,CAAC,CAAC,GAAgB,EAAE,KAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAU,EAAE,KAAK,EAAE,GAAG,CAAC,CAAoB;iBACtF,CAAC,CAAC;gBACH,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @module test-extend
3
+ *
4
+ * Fixture extension system for augmenting `TestContext` (`test.extend()`).
5
+ *
6
+ * `test.extend(fixtures)` returns an `ExtendedTest` function whose `ctx`
7
+ * includes the resolved fixture properties alongside the base `TestContext`.
8
+ * Supports chained `.extend()`, `.each()`, and `.pick()`.
9
+ * Also exports the `ExtendedTest` interface and `EachOptions`.
10
+ */
11
+ import type { ExtensionFn, ResolveExtensions, Test, TestContext, TestMeta } from "../types.js";
12
+ import { TestBuilder } from "./builder.js";
13
+ import { EachBuilder } from "./each-builder.js";
14
+ /** Keys that cannot be used as extension names (they shadow core TestContext). */
15
+ export declare const EXTEND_RESERVED_KEYS: Set<string>;
16
+ /**
17
+ * An extended `test` function created by `test.extend()`.
18
+ *
19
+ * Behaves identically to the base `test()` but augments the context type
20
+ * with fixture properties. Supports quick mode, builder mode, `.each()`,
21
+ * `.pick()`, and chained `.extend()`.
22
+ *
23
+ * @template Ctx The augmented context type (TestContext & extensions)
24
+ */
25
+ export interface ExtendedTest<Ctx extends TestContext> {
26
+ /** Quick mode: single-function test with augmented context. */
27
+ (idOrMeta: string | TestMeta, fn: (ctx: Ctx) => Promise<void>): Test;
28
+ /** Builder mode: multi-step test with augmented context. */
29
+ <S = unknown>(idOrMeta: string | TestMeta): TestBuilder<S, Ctx>;
30
+ /**
31
+ * Chain another set of extensions on top of the current ones.
32
+ * The returned test function has `Ctx & NewExtensions` as its context type.
33
+ */
34
+ extend<E extends Record<string, ExtensionFn<unknown>>>(extensions: E): ExtendedTest<Ctx & ResolveExtensions<E>>;
35
+ /** Data-driven tests with augmented context. */
36
+ each<T extends Record<string, unknown>>(table: readonly T[], options?: EachOptions): {
37
+ (idOrMeta: string | TestMeta, fn: (ctx: Ctx, data: T) => Promise<void>): Test[];
38
+ (idOrMeta: string | TestMeta): EachBuilder<unknown, T, Ctx>;
39
+ };
40
+ /** Example-selection tests with augmented context. */
41
+ pick<T extends Record<string, unknown>>(examples: Record<string, T>, count?: number): {
42
+ (idOrMeta: string | TestMeta, fn: (ctx: Ctx, data: T & {
43
+ _pick: string;
44
+ }) => Promise<void>): Test[];
45
+ (idOrMeta: string | TestMeta): EachBuilder<unknown, T & {
46
+ _pick: string;
47
+ }, Ctx>;
48
+ };
49
+ }
50
+ /** @deprecated Use `parallel` in TestMeta instead. */
51
+ export interface EachOptions {
52
+ parallel?: boolean;
53
+ }
54
+ /**
55
+ * Create an extended test function with fixture definitions.
56
+ * @internal
57
+ */
58
+ export declare function createExtendedTest<Ctx extends TestContext>(allFixtures: Record<string, ExtensionFn<any>>): ExtendedTest<Ctx>;
59
+ //# sourceMappingURL=extend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extend.d.ts","sourceRoot":"","sources":["../../src/test/extend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EAEjB,IAAI,EACJ,WAAW,EACX,QAAQ,EACT,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,kFAAkF;AAClF,eAAO,MAAM,oBAAoB,aAAuC,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY,CAAC,GAAG,SAAS,WAAW;IACnD,+DAA+D;IAC/D,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACrE,4DAA4D;IAC5D,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAEhE;;;OAGG;IACH,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,EACnD,UAAU,EAAE,CAAC,GACZ,YAAY,CAAC,GAAG,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IAE5C,gDAAgD;IAChD,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,OAAO,CA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