@jterrazz/test 6.2.0 → 6.4.1
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/dist/index.cjs +108 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -20
- package/dist/index.d.ts +68 -20
- package/dist/index.js +108 -41
- package/dist/index.js.map +1 -1
- package/dist/intercept.cjs +240 -0
- package/dist/intercept.cjs.map +1 -0
- package/dist/intercept.d.cts +89 -0
- package/dist/intercept.d.ts +89 -0
- package/dist/intercept.js +237 -0
- package/dist/intercept.js.map +1 -0
- package/dist/intercept2.cjs +79 -0
- package/dist/intercept2.cjs.map +1 -0
- package/dist/intercept2.js +79 -0
- package/dist/intercept2.js.map +1 -0
- package/dist/mock-of.cjs +2 -2
- package/dist/mock-of.cjs.map +1 -1
- package/dist/mock-of.d.cts +2 -2
- package/dist/mock-of.d.ts +2 -2
- package/dist/mock-of.js +2 -2
- package/dist/mock-of.js.map +1 -1
- package/dist/sqlite.adapter.cjs.map +1 -1
- package/dist/sqlite.adapter.d.cts +3 -3
- package/dist/sqlite.adapter.d.ts +3 -3
- package/dist/sqlite.adapter.js.map +1 -1
- package/dist/types.d.cts +35 -0
- package/dist/types.d.ts +35 -0
- package/package.json +6 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { a as PostgresOptions, c as IsolationStrategy, i as redis, l as DatabasePort, n as sqlite, o as postgres, r as RedisOptions, s as ServiceHandle, t as SqliteOptions } from "./sqlite.adapter.cjs";
|
|
2
|
+
import { n as InterceptResponse, r as InterceptTrigger } from "./types.cjs";
|
|
2
3
|
import { i as mockOfDate, n as mockOf, r as MockDatePort, t as MockPort } from "./mock-of.cjs";
|
|
3
4
|
|
|
4
|
-
//#region src/
|
|
5
|
+
//#region src/builder/cli/command.port.d.ts
|
|
5
6
|
/**
|
|
6
7
|
* Result of executing a CLI command, including exit code and captured output streams.
|
|
7
8
|
*/
|
|
@@ -38,7 +39,7 @@ interface CommandPort {
|
|
|
38
39
|
spawn(args: string, cwd: string, options: SpawnOptions, env?: CommandEnv): Promise<CommandResult>;
|
|
39
40
|
}
|
|
40
41
|
//#endregion
|
|
41
|
-
//#region src/
|
|
42
|
+
//#region src/builder/http/server.port.d.ts
|
|
42
43
|
/**
|
|
43
44
|
* HTTP response returned by a server port, with parsed JSON body.
|
|
44
45
|
*/
|
|
@@ -59,7 +60,7 @@ interface ServerPort {
|
|
|
59
60
|
request(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<ServerResponse>;
|
|
60
61
|
}
|
|
61
62
|
//#endregion
|
|
62
|
-
//#region src/builder/directory-accessor.d.ts
|
|
63
|
+
//#region src/builder/common/directory-accessor.d.ts
|
|
63
64
|
interface DirectorySnapshotOptions {
|
|
64
65
|
/** Extra path segments to ignore (in addition to default: .git, node_modules, etc.). */
|
|
65
66
|
ignore?: string[];
|
|
@@ -92,7 +93,7 @@ declare class DirectoryAccessor {
|
|
|
92
93
|
}): Promise<string[]>;
|
|
93
94
|
}
|
|
94
95
|
//#endregion
|
|
95
|
-
//#region src/builder/response-accessor.d.ts
|
|
96
|
+
//#region src/builder/common/response-accessor.d.ts
|
|
96
97
|
/** Accessor for an HTTP response body with file-based assertion support. */
|
|
97
98
|
declare class ResponseAccessor {
|
|
98
99
|
readonly body: unknown;
|
|
@@ -107,7 +108,7 @@ declare class ResponseAccessor {
|
|
|
107
108
|
toMatchFile(file: string): void;
|
|
108
109
|
}
|
|
109
110
|
//#endregion
|
|
110
|
-
//#region src/builder/table-assertion.d.ts
|
|
111
|
+
//#region src/builder/common/table-assertion.d.ts
|
|
111
112
|
/** Assertion helper for verifying database table contents after a specification run. */
|
|
112
113
|
declare class TableAssertion {
|
|
113
114
|
private tableName;
|
|
@@ -130,7 +131,7 @@ declare class TableAssertion {
|
|
|
130
131
|
toBeEmpty(): Promise<void>;
|
|
131
132
|
}
|
|
132
133
|
//#endregion
|
|
133
|
-
//#region src/builder/
|
|
134
|
+
//#region src/builder/common/result.d.ts
|
|
134
135
|
/** Read-only handle to a single file produced by a CLI action. */
|
|
135
136
|
interface FileAccessor {
|
|
136
137
|
/** The UTF-8 text content. Throws if the file does not exist. */
|
|
@@ -190,12 +191,18 @@ declare class SpecificationResult {
|
|
|
190
191
|
}
|
|
191
192
|
//#endregion
|
|
192
193
|
//#region src/builder/specification-builder.d.ts
|
|
194
|
+
/** A named job that can be triggered via .job(). */
|
|
195
|
+
interface JobHandle$1 {
|
|
196
|
+
name: string;
|
|
197
|
+
execute: () => Promise<void>;
|
|
198
|
+
}
|
|
193
199
|
/** Adapter configuration passed to the specification runner at setup time. */
|
|
194
200
|
interface SpecificationConfig {
|
|
195
201
|
command?: CommandPort;
|
|
196
202
|
database?: DatabasePort;
|
|
197
203
|
databases?: Map<string, DatabasePort>;
|
|
198
204
|
fixturesRoot?: string;
|
|
205
|
+
jobs?: JobHandle$1[];
|
|
199
206
|
server?: ServerPort;
|
|
200
207
|
}
|
|
201
208
|
/**
|
|
@@ -210,6 +217,8 @@ declare class SpecificationBuilder {
|
|
|
210
217
|
private commandEnv;
|
|
211
218
|
private config;
|
|
212
219
|
private fixtures;
|
|
220
|
+
private intercepts;
|
|
221
|
+
private jobName;
|
|
213
222
|
private label;
|
|
214
223
|
private mocks;
|
|
215
224
|
private projectName;
|
|
@@ -252,6 +261,22 @@ declare class SpecificationBuilder {
|
|
|
252
261
|
* spec("french").headers({ 'Accept-Language': 'fr' }).get("/articles").run();
|
|
253
262
|
*/
|
|
254
263
|
headers(headers: Record<string, string>): this;
|
|
264
|
+
/**
|
|
265
|
+
* Intercept an outgoing HTTP request and return a controlled response.
|
|
266
|
+
* Uses MSW under the hood. Intercepts are queued — multiple calls with the
|
|
267
|
+
* same trigger fire sequentially (first match consumed first).
|
|
268
|
+
*
|
|
269
|
+
* @param trigger - What to match (use openai.chat(), anthropic.messages(), http.get(), etc.)
|
|
270
|
+
* @param response - What to return (use openai.response(), http.json(), etc.)
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* spec('pipeline')
|
|
274
|
+
* .intercept(openai.chat(), openai.response({ categories: ['TECH'] }))
|
|
275
|
+
* .intercept(openai.chat(), openai.response({ headline: 'AI News' }))
|
|
276
|
+
* .exec('process')
|
|
277
|
+
* .run();
|
|
278
|
+
*/
|
|
279
|
+
intercept(trigger: InterceptTrigger, response: InterceptResponse): this;
|
|
255
280
|
/**
|
|
256
281
|
* Send a GET request to the server adapter.
|
|
257
282
|
*
|
|
@@ -282,6 +307,15 @@ declare class SpecificationBuilder {
|
|
|
282
307
|
exec(args: string | string[]): this;
|
|
283
308
|
/** Spawn a long-running CLI process with custom spawn options (e.g. timeout, signal). */
|
|
284
309
|
spawn(args: string, options: SpawnOptions): this;
|
|
310
|
+
/**
|
|
311
|
+
* Execute a named job registered via the app() factory.
|
|
312
|
+
*
|
|
313
|
+
* @param name - The job name to trigger (must match a registered JobHandle.name).
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* spec('pipeline').intercept(openai.chat(), openai.response({...})).job('report-refresh').run();
|
|
317
|
+
*/
|
|
318
|
+
job(name: string): this;
|
|
285
319
|
/**
|
|
286
320
|
* Execute the specification: run seeds, copy fixtures, then perform the
|
|
287
321
|
* configured action (HTTP or CLI).
|
|
@@ -295,6 +329,7 @@ declare class SpecificationBuilder {
|
|
|
295
329
|
private resolveEnv;
|
|
296
330
|
private prepareWorkDir;
|
|
297
331
|
private runHttpAction;
|
|
332
|
+
private runJobAction;
|
|
298
333
|
private runCliAction;
|
|
299
334
|
}
|
|
300
335
|
/** Factory function returned by `cli()`, `integration()`, or `e2e()` that starts a new spec. */
|
|
@@ -391,7 +426,7 @@ declare class DockerAssertion {
|
|
|
391
426
|
getLogs(tail?: number): Promise<string>;
|
|
392
427
|
}
|
|
393
428
|
//#endregion
|
|
394
|
-
//#region src/
|
|
429
|
+
//#region src/infra/orchestrator.d.ts
|
|
395
430
|
interface OrchestratorOptions {
|
|
396
431
|
services: ServiceHandle[];
|
|
397
432
|
mode: 'e2e' | 'integration';
|
|
@@ -447,17 +482,30 @@ declare class Orchestrator {
|
|
|
447
482
|
getAppUrl(): null | string;
|
|
448
483
|
}
|
|
449
484
|
//#endregion
|
|
450
|
-
//#region src/
|
|
485
|
+
//#region src/spec/targets.d.ts
|
|
451
486
|
/** Any object with a request method compatible with Hono's app.request(). */
|
|
452
487
|
type HonoApp$1 = {
|
|
453
488
|
request: (path: string, init?: RequestInit) => Promise<Response> | Response;
|
|
454
489
|
};
|
|
490
|
+
/** A named job that can be triggered via .job(). */
|
|
491
|
+
interface JobHandle {
|
|
492
|
+
name: string;
|
|
493
|
+
execute: () => Promise<void>;
|
|
494
|
+
}
|
|
455
495
|
/** Services map passed to the app factory after infrastructure starts. */
|
|
456
496
|
type AppServices = Record<string, ServiceHandle>;
|
|
497
|
+
/**
|
|
498
|
+
* Return value from the app() factory. Either a bare server (backward compat)
|
|
499
|
+
* or an object with server + jobs for job-based testing.
|
|
500
|
+
*/
|
|
501
|
+
type AppFactoryResult = HonoApp$1 | {
|
|
502
|
+
server: HonoApp$1;
|
|
503
|
+
jobs: JobHandle[];
|
|
504
|
+
};
|
|
457
505
|
/** In-process Hono app target. Created by {@link app}. */
|
|
458
506
|
interface AppTarget {
|
|
459
507
|
readonly kind: 'app';
|
|
460
|
-
readonly factory: (services: AppServices) =>
|
|
508
|
+
readonly factory: (services: AppServices) => AppFactoryResult;
|
|
461
509
|
}
|
|
462
510
|
/** Docker compose stack target. Created by {@link stack}. */
|
|
463
511
|
interface StackTarget {
|
|
@@ -507,7 +555,7 @@ declare function stack(root: string): StackTarget;
|
|
|
507
555
|
*/
|
|
508
556
|
declare function command(bin: string): CommandTarget;
|
|
509
557
|
//#endregion
|
|
510
|
-
//#region src/
|
|
558
|
+
//#region src/spec/spec.d.ts
|
|
511
559
|
/** Shared options for all spec targets. */
|
|
512
560
|
interface SpecOptions {
|
|
513
561
|
/** Project root for fixture lookup and compose detection (relative paths supported). */
|
|
@@ -549,7 +597,7 @@ interface SpecRunner {
|
|
|
549
597
|
*/
|
|
550
598
|
declare function spec(target: SpecTarget, options?: SpecOptions): Promise<SpecRunner>;
|
|
551
599
|
//#endregion
|
|
552
|
-
//#region src/ports/container.port.d.ts
|
|
600
|
+
//#region src/infra/ports/container.port.d.ts
|
|
553
601
|
/**
|
|
554
602
|
* Abstract container interface.
|
|
555
603
|
* Represents a running service (database, cache, etc.)
|
|
@@ -569,7 +617,7 @@ interface ContainerPort {
|
|
|
569
617
|
getLogs(): Promise<string>;
|
|
570
618
|
}
|
|
571
619
|
//#endregion
|
|
572
|
-
//#region src/adapters/exec.adapter.d.ts
|
|
620
|
+
//#region src/builder/cli/adapters/exec.adapter.d.ts
|
|
573
621
|
/**
|
|
574
622
|
* Executes CLI commands via Node.js child_process.
|
|
575
623
|
* Uses `execSync` for one-shot commands and `spawn` for long-running processes.
|
|
@@ -582,7 +630,7 @@ declare class ExecAdapter implements CommandPort {
|
|
|
582
630
|
spawn(args: string, cwd: string, options: SpawnOptions, extraEnv?: CommandEnv): Promise<CommandResult>;
|
|
583
631
|
}
|
|
584
632
|
//#endregion
|
|
585
|
-
//#region src/adapters/fetch.adapter.d.ts
|
|
633
|
+
//#region src/builder/http/adapters/fetch.adapter.d.ts
|
|
586
634
|
/**
|
|
587
635
|
* Server adapter that sends real HTTP requests via the Fetch API.
|
|
588
636
|
* Used by the `e2e()` specification runner to hit a live server.
|
|
@@ -593,7 +641,7 @@ declare class FetchAdapter implements ServerPort {
|
|
|
593
641
|
request(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<ServerResponse>;
|
|
594
642
|
}
|
|
595
643
|
//#endregion
|
|
596
|
-
//#region src/adapters/hono.adapter.d.ts
|
|
644
|
+
//#region src/builder/http/adapters/hono.adapter.d.ts
|
|
597
645
|
/**
|
|
598
646
|
* Server adapter that dispatches requests in-process through a Hono app instance.
|
|
599
647
|
* Used by the `integration()` specification runner -- no network overhead.
|
|
@@ -606,7 +654,7 @@ declare class HonoAdapter implements ServerPort {
|
|
|
606
654
|
request(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<ServerResponse>;
|
|
607
655
|
}
|
|
608
656
|
//#endregion
|
|
609
|
-
//#region src/
|
|
657
|
+
//#region src/spec/legacy-integration.d.ts
|
|
610
658
|
type HonoApp = {
|
|
611
659
|
fetch: (...args: any[]) => any;
|
|
612
660
|
request: (path: string, init?: RequestInit) => Promise<Response> | Response;
|
|
@@ -632,7 +680,7 @@ interface SpecificationRunnerWithCleanup extends SpecificationRunner {
|
|
|
632
680
|
*/
|
|
633
681
|
declare function integration(options: IntegrationOptions): Promise<SpecificationRunnerWithCleanup>;
|
|
634
682
|
//#endregion
|
|
635
|
-
//#region src/
|
|
683
|
+
//#region src/spec/legacy-cli.d.ts
|
|
636
684
|
interface CliOptions {
|
|
637
685
|
/** CLI command to run (resolved from node_modules/.bin or PATH). */
|
|
638
686
|
command: string;
|
|
@@ -647,7 +695,7 @@ interface CliOptions {
|
|
|
647
695
|
*/
|
|
648
696
|
declare function cli(options: CliOptions): Promise<SpecificationRunnerWithCleanup>;
|
|
649
697
|
//#endregion
|
|
650
|
-
//#region src/
|
|
698
|
+
//#region src/spec/legacy-e2e.d.ts
|
|
651
699
|
interface E2eOptions {
|
|
652
700
|
/** Project root — must contain docker/compose.test.yaml. */
|
|
653
701
|
root?: string;
|
|
@@ -658,7 +706,7 @@ interface E2eOptions {
|
|
|
658
706
|
*/
|
|
659
707
|
declare function e2e(options?: E2eOptions): Promise<SpecificationRunnerWithCleanup>;
|
|
660
708
|
//#endregion
|
|
661
|
-
//#region src/
|
|
709
|
+
//#region src/builder/common/grep.d.ts
|
|
662
710
|
/**
|
|
663
711
|
* Extract text blocks from output that contain a pattern.
|
|
664
712
|
* Splits by blank lines (how linter/compiler output is structured),
|
|
@@ -670,7 +718,7 @@ declare function e2e(options?: E2eOptions): Promise<SpecificationRunnerWithClean
|
|
|
670
718
|
*/
|
|
671
719
|
declare function grep(output: string, pattern: string): string;
|
|
672
720
|
//#endregion
|
|
673
|
-
//#region src/
|
|
721
|
+
//#region src/builder/common/reporter.d.ts
|
|
674
722
|
/** Strip ANSI escape codes from a string. */
|
|
675
723
|
declare function stripAnsi(str: string): string;
|
|
676
724
|
/** Strip ANSI codes and replace volatile tokens (ports, durations) with placeholders. */
|
|
@@ -680,5 +728,5 @@ declare function normalizeOutput(str: string): string;
|
|
|
680
728
|
/** Create a {@link DockerContainerPort} bound to an existing container by ID. */
|
|
681
729
|
declare function dockerContainer(containerId: string): DockerContainerPort;
|
|
682
730
|
//#endregion
|
|
683
|
-
export { type AppServices, type AppTarget, type CliOptions, type CommandEnv, type CommandPort, type CommandResult, type CommandTarget, type ContainerPort, type DatabasePort, DirectoryAccessor, type DirectorySnapshotOptions, DockerAssertion, type DockerContainerPort, type DockerInspectResult, type E2eOptions, ExecAdapter, FetchAdapter, type FileAccessor, HonoAdapter, type HttpTarget, type IntegrationOptions, type IsolationStrategy, type MockDatePort, type MockPort, Orchestrator, type PostgresOptions, type RedisOptions, ResponseAccessor, type ServerPort, type ServerResponse, type ServiceHandle, type SpawnOptions, type SpecOptions, type SpecRunner, type SpecTarget, SpecificationBuilder, type SpecificationConfig, SpecificationResult, type SpecificationRunner, type SpecificationRunnerWithCleanup, type SqliteOptions, type StackTarget, TableAssertion, app, cli, command, createSpecificationRunner, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, spec, sqlite, stack, stripAnsi };
|
|
731
|
+
export { type AppFactoryResult, type AppServices, type AppTarget, type CliOptions, type CommandEnv, type CommandPort, type CommandResult, type CommandTarget, type ContainerPort, type DatabasePort, DirectoryAccessor, type DirectorySnapshotOptions, DockerAssertion, type DockerContainerPort, type DockerInspectResult, type E2eOptions, ExecAdapter, FetchAdapter, type FileAccessor, HonoAdapter, type HttpTarget, type IntegrationOptions, type IsolationStrategy, type JobHandle, type MockDatePort, type MockPort, Orchestrator, type PostgresOptions, type RedisOptions, ResponseAccessor, type ServerPort, type ServerResponse, type ServiceHandle, type SpawnOptions, type SpecOptions, type SpecRunner, type SpecTarget, SpecificationBuilder, type SpecificationConfig, SpecificationResult, type SpecificationRunner, type SpecificationRunnerWithCleanup, type SqliteOptions, type StackTarget, TableAssertion, app, cli, command, createSpecificationRunner, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, spec, sqlite, stack, stripAnsi };
|
|
684
732
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { a as PostgresOptions, c as IsolationStrategy, i as redis, l as DatabasePort, n as sqlite, o as postgres, r as RedisOptions, s as ServiceHandle, t as SqliteOptions } from "./sqlite.adapter.js";
|
|
2
|
+
import { n as InterceptResponse, r as InterceptTrigger } from "./types.js";
|
|
2
3
|
import { i as mockOfDate, n as mockOf, r as MockDatePort, t as MockPort } from "./mock-of.js";
|
|
3
4
|
|
|
4
|
-
//#region src/
|
|
5
|
+
//#region src/builder/cli/command.port.d.ts
|
|
5
6
|
/**
|
|
6
7
|
* Result of executing a CLI command, including exit code and captured output streams.
|
|
7
8
|
*/
|
|
@@ -38,7 +39,7 @@ interface CommandPort {
|
|
|
38
39
|
spawn(args: string, cwd: string, options: SpawnOptions, env?: CommandEnv): Promise<CommandResult>;
|
|
39
40
|
}
|
|
40
41
|
//#endregion
|
|
41
|
-
//#region src/
|
|
42
|
+
//#region src/builder/http/server.port.d.ts
|
|
42
43
|
/**
|
|
43
44
|
* HTTP response returned by a server port, with parsed JSON body.
|
|
44
45
|
*/
|
|
@@ -59,7 +60,7 @@ interface ServerPort {
|
|
|
59
60
|
request(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<ServerResponse>;
|
|
60
61
|
}
|
|
61
62
|
//#endregion
|
|
62
|
-
//#region src/builder/directory-accessor.d.ts
|
|
63
|
+
//#region src/builder/common/directory-accessor.d.ts
|
|
63
64
|
interface DirectorySnapshotOptions {
|
|
64
65
|
/** Extra path segments to ignore (in addition to default: .git, node_modules, etc.). */
|
|
65
66
|
ignore?: string[];
|
|
@@ -92,7 +93,7 @@ declare class DirectoryAccessor {
|
|
|
92
93
|
}): Promise<string[]>;
|
|
93
94
|
}
|
|
94
95
|
//#endregion
|
|
95
|
-
//#region src/builder/response-accessor.d.ts
|
|
96
|
+
//#region src/builder/common/response-accessor.d.ts
|
|
96
97
|
/** Accessor for an HTTP response body with file-based assertion support. */
|
|
97
98
|
declare class ResponseAccessor {
|
|
98
99
|
readonly body: unknown;
|
|
@@ -107,7 +108,7 @@ declare class ResponseAccessor {
|
|
|
107
108
|
toMatchFile(file: string): void;
|
|
108
109
|
}
|
|
109
110
|
//#endregion
|
|
110
|
-
//#region src/builder/table-assertion.d.ts
|
|
111
|
+
//#region src/builder/common/table-assertion.d.ts
|
|
111
112
|
/** Assertion helper for verifying database table contents after a specification run. */
|
|
112
113
|
declare class TableAssertion {
|
|
113
114
|
private tableName;
|
|
@@ -130,7 +131,7 @@ declare class TableAssertion {
|
|
|
130
131
|
toBeEmpty(): Promise<void>;
|
|
131
132
|
}
|
|
132
133
|
//#endregion
|
|
133
|
-
//#region src/builder/
|
|
134
|
+
//#region src/builder/common/result.d.ts
|
|
134
135
|
/** Read-only handle to a single file produced by a CLI action. */
|
|
135
136
|
interface FileAccessor {
|
|
136
137
|
/** The UTF-8 text content. Throws if the file does not exist. */
|
|
@@ -190,12 +191,18 @@ declare class SpecificationResult {
|
|
|
190
191
|
}
|
|
191
192
|
//#endregion
|
|
192
193
|
//#region src/builder/specification-builder.d.ts
|
|
194
|
+
/** A named job that can be triggered via .job(). */
|
|
195
|
+
interface JobHandle$1 {
|
|
196
|
+
name: string;
|
|
197
|
+
execute: () => Promise<void>;
|
|
198
|
+
}
|
|
193
199
|
/** Adapter configuration passed to the specification runner at setup time. */
|
|
194
200
|
interface SpecificationConfig {
|
|
195
201
|
command?: CommandPort;
|
|
196
202
|
database?: DatabasePort;
|
|
197
203
|
databases?: Map<string, DatabasePort>;
|
|
198
204
|
fixturesRoot?: string;
|
|
205
|
+
jobs?: JobHandle$1[];
|
|
199
206
|
server?: ServerPort;
|
|
200
207
|
}
|
|
201
208
|
/**
|
|
@@ -210,6 +217,8 @@ declare class SpecificationBuilder {
|
|
|
210
217
|
private commandEnv;
|
|
211
218
|
private config;
|
|
212
219
|
private fixtures;
|
|
220
|
+
private intercepts;
|
|
221
|
+
private jobName;
|
|
213
222
|
private label;
|
|
214
223
|
private mocks;
|
|
215
224
|
private projectName;
|
|
@@ -252,6 +261,22 @@ declare class SpecificationBuilder {
|
|
|
252
261
|
* spec("french").headers({ 'Accept-Language': 'fr' }).get("/articles").run();
|
|
253
262
|
*/
|
|
254
263
|
headers(headers: Record<string, string>): this;
|
|
264
|
+
/**
|
|
265
|
+
* Intercept an outgoing HTTP request and return a controlled response.
|
|
266
|
+
* Uses MSW under the hood. Intercepts are queued — multiple calls with the
|
|
267
|
+
* same trigger fire sequentially (first match consumed first).
|
|
268
|
+
*
|
|
269
|
+
* @param trigger - What to match (use openai.chat(), anthropic.messages(), http.get(), etc.)
|
|
270
|
+
* @param response - What to return (use openai.response(), http.json(), etc.)
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* spec('pipeline')
|
|
274
|
+
* .intercept(openai.chat(), openai.response({ categories: ['TECH'] }))
|
|
275
|
+
* .intercept(openai.chat(), openai.response({ headline: 'AI News' }))
|
|
276
|
+
* .exec('process')
|
|
277
|
+
* .run();
|
|
278
|
+
*/
|
|
279
|
+
intercept(trigger: InterceptTrigger, response: InterceptResponse): this;
|
|
255
280
|
/**
|
|
256
281
|
* Send a GET request to the server adapter.
|
|
257
282
|
*
|
|
@@ -282,6 +307,15 @@ declare class SpecificationBuilder {
|
|
|
282
307
|
exec(args: string | string[]): this;
|
|
283
308
|
/** Spawn a long-running CLI process with custom spawn options (e.g. timeout, signal). */
|
|
284
309
|
spawn(args: string, options: SpawnOptions): this;
|
|
310
|
+
/**
|
|
311
|
+
* Execute a named job registered via the app() factory.
|
|
312
|
+
*
|
|
313
|
+
* @param name - The job name to trigger (must match a registered JobHandle.name).
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* spec('pipeline').intercept(openai.chat(), openai.response({...})).job('report-refresh').run();
|
|
317
|
+
*/
|
|
318
|
+
job(name: string): this;
|
|
285
319
|
/**
|
|
286
320
|
* Execute the specification: run seeds, copy fixtures, then perform the
|
|
287
321
|
* configured action (HTTP or CLI).
|
|
@@ -295,6 +329,7 @@ declare class SpecificationBuilder {
|
|
|
295
329
|
private resolveEnv;
|
|
296
330
|
private prepareWorkDir;
|
|
297
331
|
private runHttpAction;
|
|
332
|
+
private runJobAction;
|
|
298
333
|
private runCliAction;
|
|
299
334
|
}
|
|
300
335
|
/** Factory function returned by `cli()`, `integration()`, or `e2e()` that starts a new spec. */
|
|
@@ -391,7 +426,7 @@ declare class DockerAssertion {
|
|
|
391
426
|
getLogs(tail?: number): Promise<string>;
|
|
392
427
|
}
|
|
393
428
|
//#endregion
|
|
394
|
-
//#region src/
|
|
429
|
+
//#region src/infra/orchestrator.d.ts
|
|
395
430
|
interface OrchestratorOptions {
|
|
396
431
|
services: ServiceHandle[];
|
|
397
432
|
mode: 'e2e' | 'integration';
|
|
@@ -447,17 +482,30 @@ declare class Orchestrator {
|
|
|
447
482
|
getAppUrl(): null | string;
|
|
448
483
|
}
|
|
449
484
|
//#endregion
|
|
450
|
-
//#region src/
|
|
485
|
+
//#region src/spec/targets.d.ts
|
|
451
486
|
/** Any object with a request method compatible with Hono's app.request(). */
|
|
452
487
|
type HonoApp$1 = {
|
|
453
488
|
request: (path: string, init?: RequestInit) => Promise<Response> | Response;
|
|
454
489
|
};
|
|
490
|
+
/** A named job that can be triggered via .job(). */
|
|
491
|
+
interface JobHandle {
|
|
492
|
+
name: string;
|
|
493
|
+
execute: () => Promise<void>;
|
|
494
|
+
}
|
|
455
495
|
/** Services map passed to the app factory after infrastructure starts. */
|
|
456
496
|
type AppServices = Record<string, ServiceHandle>;
|
|
497
|
+
/**
|
|
498
|
+
* Return value from the app() factory. Either a bare server (backward compat)
|
|
499
|
+
* or an object with server + jobs for job-based testing.
|
|
500
|
+
*/
|
|
501
|
+
type AppFactoryResult = HonoApp$1 | {
|
|
502
|
+
server: HonoApp$1;
|
|
503
|
+
jobs: JobHandle[];
|
|
504
|
+
};
|
|
457
505
|
/** In-process Hono app target. Created by {@link app}. */
|
|
458
506
|
interface AppTarget {
|
|
459
507
|
readonly kind: 'app';
|
|
460
|
-
readonly factory: (services: AppServices) =>
|
|
508
|
+
readonly factory: (services: AppServices) => AppFactoryResult;
|
|
461
509
|
}
|
|
462
510
|
/** Docker compose stack target. Created by {@link stack}. */
|
|
463
511
|
interface StackTarget {
|
|
@@ -507,7 +555,7 @@ declare function stack(root: string): StackTarget;
|
|
|
507
555
|
*/
|
|
508
556
|
declare function command(bin: string): CommandTarget;
|
|
509
557
|
//#endregion
|
|
510
|
-
//#region src/
|
|
558
|
+
//#region src/spec/spec.d.ts
|
|
511
559
|
/** Shared options for all spec targets. */
|
|
512
560
|
interface SpecOptions {
|
|
513
561
|
/** Project root for fixture lookup and compose detection (relative paths supported). */
|
|
@@ -549,7 +597,7 @@ interface SpecRunner {
|
|
|
549
597
|
*/
|
|
550
598
|
declare function spec(target: SpecTarget, options?: SpecOptions): Promise<SpecRunner>;
|
|
551
599
|
//#endregion
|
|
552
|
-
//#region src/ports/container.port.d.ts
|
|
600
|
+
//#region src/infra/ports/container.port.d.ts
|
|
553
601
|
/**
|
|
554
602
|
* Abstract container interface.
|
|
555
603
|
* Represents a running service (database, cache, etc.)
|
|
@@ -569,7 +617,7 @@ interface ContainerPort {
|
|
|
569
617
|
getLogs(): Promise<string>;
|
|
570
618
|
}
|
|
571
619
|
//#endregion
|
|
572
|
-
//#region src/adapters/exec.adapter.d.ts
|
|
620
|
+
//#region src/builder/cli/adapters/exec.adapter.d.ts
|
|
573
621
|
/**
|
|
574
622
|
* Executes CLI commands via Node.js child_process.
|
|
575
623
|
* Uses `execSync` for one-shot commands and `spawn` for long-running processes.
|
|
@@ -582,7 +630,7 @@ declare class ExecAdapter implements CommandPort {
|
|
|
582
630
|
spawn(args: string, cwd: string, options: SpawnOptions, extraEnv?: CommandEnv): Promise<CommandResult>;
|
|
583
631
|
}
|
|
584
632
|
//#endregion
|
|
585
|
-
//#region src/adapters/fetch.adapter.d.ts
|
|
633
|
+
//#region src/builder/http/adapters/fetch.adapter.d.ts
|
|
586
634
|
/**
|
|
587
635
|
* Server adapter that sends real HTTP requests via the Fetch API.
|
|
588
636
|
* Used by the `e2e()` specification runner to hit a live server.
|
|
@@ -593,7 +641,7 @@ declare class FetchAdapter implements ServerPort {
|
|
|
593
641
|
request(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<ServerResponse>;
|
|
594
642
|
}
|
|
595
643
|
//#endregion
|
|
596
|
-
//#region src/adapters/hono.adapter.d.ts
|
|
644
|
+
//#region src/builder/http/adapters/hono.adapter.d.ts
|
|
597
645
|
/**
|
|
598
646
|
* Server adapter that dispatches requests in-process through a Hono app instance.
|
|
599
647
|
* Used by the `integration()` specification runner -- no network overhead.
|
|
@@ -606,7 +654,7 @@ declare class HonoAdapter implements ServerPort {
|
|
|
606
654
|
request(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<ServerResponse>;
|
|
607
655
|
}
|
|
608
656
|
//#endregion
|
|
609
|
-
//#region src/
|
|
657
|
+
//#region src/spec/legacy-integration.d.ts
|
|
610
658
|
type HonoApp = {
|
|
611
659
|
fetch: (...args: any[]) => any;
|
|
612
660
|
request: (path: string, init?: RequestInit) => Promise<Response> | Response;
|
|
@@ -632,7 +680,7 @@ interface SpecificationRunnerWithCleanup extends SpecificationRunner {
|
|
|
632
680
|
*/
|
|
633
681
|
declare function integration(options: IntegrationOptions): Promise<SpecificationRunnerWithCleanup>;
|
|
634
682
|
//#endregion
|
|
635
|
-
//#region src/
|
|
683
|
+
//#region src/spec/legacy-cli.d.ts
|
|
636
684
|
interface CliOptions {
|
|
637
685
|
/** CLI command to run (resolved from node_modules/.bin or PATH). */
|
|
638
686
|
command: string;
|
|
@@ -647,7 +695,7 @@ interface CliOptions {
|
|
|
647
695
|
*/
|
|
648
696
|
declare function cli(options: CliOptions): Promise<SpecificationRunnerWithCleanup>;
|
|
649
697
|
//#endregion
|
|
650
|
-
//#region src/
|
|
698
|
+
//#region src/spec/legacy-e2e.d.ts
|
|
651
699
|
interface E2eOptions {
|
|
652
700
|
/** Project root — must contain docker/compose.test.yaml. */
|
|
653
701
|
root?: string;
|
|
@@ -658,7 +706,7 @@ interface E2eOptions {
|
|
|
658
706
|
*/
|
|
659
707
|
declare function e2e(options?: E2eOptions): Promise<SpecificationRunnerWithCleanup>;
|
|
660
708
|
//#endregion
|
|
661
|
-
//#region src/
|
|
709
|
+
//#region src/builder/common/grep.d.ts
|
|
662
710
|
/**
|
|
663
711
|
* Extract text blocks from output that contain a pattern.
|
|
664
712
|
* Splits by blank lines (how linter/compiler output is structured),
|
|
@@ -670,7 +718,7 @@ declare function e2e(options?: E2eOptions): Promise<SpecificationRunnerWithClean
|
|
|
670
718
|
*/
|
|
671
719
|
declare function grep(output: string, pattern: string): string;
|
|
672
720
|
//#endregion
|
|
673
|
-
//#region src/
|
|
721
|
+
//#region src/builder/common/reporter.d.ts
|
|
674
722
|
/** Strip ANSI escape codes from a string. */
|
|
675
723
|
declare function stripAnsi(str: string): string;
|
|
676
724
|
/** Strip ANSI codes and replace volatile tokens (ports, durations) with placeholders. */
|
|
@@ -680,5 +728,5 @@ declare function normalizeOutput(str: string): string;
|
|
|
680
728
|
/** Create a {@link DockerContainerPort} bound to an existing container by ID. */
|
|
681
729
|
declare function dockerContainer(containerId: string): DockerContainerPort;
|
|
682
730
|
//#endregion
|
|
683
|
-
export { type AppServices, type AppTarget, type CliOptions, type CommandEnv, type CommandPort, type CommandResult, type CommandTarget, type ContainerPort, type DatabasePort, DirectoryAccessor, type DirectorySnapshotOptions, DockerAssertion, type DockerContainerPort, type DockerInspectResult, type E2eOptions, ExecAdapter, FetchAdapter, type FileAccessor, HonoAdapter, type HttpTarget, type IntegrationOptions, type IsolationStrategy, type MockDatePort, type MockPort, Orchestrator, type PostgresOptions, type RedisOptions, ResponseAccessor, type ServerPort, type ServerResponse, type ServiceHandle, type SpawnOptions, type SpecOptions, type SpecRunner, type SpecTarget, SpecificationBuilder, type SpecificationConfig, SpecificationResult, type SpecificationRunner, type SpecificationRunnerWithCleanup, type SqliteOptions, type StackTarget, TableAssertion, app, cli, command, createSpecificationRunner, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, spec, sqlite, stack, stripAnsi };
|
|
731
|
+
export { type AppFactoryResult, type AppServices, type AppTarget, type CliOptions, type CommandEnv, type CommandPort, type CommandResult, type CommandTarget, type ContainerPort, type DatabasePort, DirectoryAccessor, type DirectorySnapshotOptions, DockerAssertion, type DockerContainerPort, type DockerInspectResult, type E2eOptions, ExecAdapter, FetchAdapter, type FileAccessor, HonoAdapter, type HttpTarget, type IntegrationOptions, type IsolationStrategy, type JobHandle, type MockDatePort, type MockPort, Orchestrator, type PostgresOptions, type RedisOptions, ResponseAccessor, type ServerPort, type ServerResponse, type ServiceHandle, type SpawnOptions, type SpecOptions, type SpecRunner, type SpecTarget, SpecificationBuilder, type SpecificationConfig, SpecificationResult, type SpecificationRunner, type SpecificationRunnerWithCleanup, type SqliteOptions, type StackTarget, TableAssertion, app, cli, command, createSpecificationRunner, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, spec, sqlite, stack, stripAnsi };
|
|
684
732
|
//# sourceMappingURL=index.d.ts.map
|