@jterrazz/test 7.1.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +209 -230
  2. package/dist/checker.d.ts +1 -0
  3. package/dist/checker.js +741 -0
  4. package/dist/index.d.ts +1296 -529
  5. package/dist/index.js +3303 -1261
  6. package/dist/intercept.js +129 -290
  7. package/dist/match.js +153 -0
  8. package/dist/oxlint.cjs +2931 -0
  9. package/dist/oxlint.d.cts +150 -0
  10. package/dist/oxlint.d.ts +150 -0
  11. package/dist/oxlint.js +2925 -0
  12. package/package.json +47 -41
  13. package/dist/chunk.cjs +0 -28
  14. package/dist/index.cjs +0 -1814
  15. package/dist/index.cjs.map +0 -1
  16. package/dist/index.d.cts +0 -734
  17. package/dist/index.js.map +0 -1
  18. package/dist/intercept.cjs +0 -313
  19. package/dist/intercept.cjs.map +0 -1
  20. package/dist/intercept.d.cts +0 -105
  21. package/dist/intercept.d.ts +0 -105
  22. package/dist/intercept.js.map +0 -1
  23. package/dist/intercept2.cjs +0 -81
  24. package/dist/intercept2.cjs.map +0 -1
  25. package/dist/intercept2.js +0 -81
  26. package/dist/intercept2.js.map +0 -1
  27. package/dist/mock-of.cjs +0 -32
  28. package/dist/mock-of.cjs.map +0 -1
  29. package/dist/mock-of.d.cts +0 -27
  30. package/dist/mock-of.d.ts +0 -27
  31. package/dist/mock-of.js +0 -19
  32. package/dist/mock-of.js.map +0 -1
  33. package/dist/mock.cjs +0 -4
  34. package/dist/mock.d.cts +0 -2
  35. package/dist/mock.d.ts +0 -2
  36. package/dist/mock.js +0 -2
  37. package/dist/services.cjs +0 -5
  38. package/dist/services.d.cts +0 -2
  39. package/dist/services.d.ts +0 -2
  40. package/dist/services.js +0 -2
  41. package/dist/sqlite.adapter.cjs +0 -350
  42. package/dist/sqlite.adapter.cjs.map +0 -1
  43. package/dist/sqlite.adapter.d.cts +0 -209
  44. package/dist/sqlite.adapter.d.ts +0 -209
  45. package/dist/sqlite.adapter.js +0 -331
  46. package/dist/sqlite.adapter.js.map +0 -1
  47. package/dist/types.d.cts +0 -42
  48. package/dist/types.d.ts +0 -42
package/dist/index.d.cts DELETED
@@ -1,734 +0,0 @@
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";
3
- import { i as mockOfDate, n as mockOf, r as MockDatePort, t as MockPort } from "./mock-of.cjs";
4
-
5
- //#region src/builder/cli/command.port.d.ts
6
- /**
7
- * Result of executing a CLI command, including exit code and captured output streams.
8
- */
9
- interface CommandResult {
10
- /** Process exit code (0 = success). */
11
- exitCode: number;
12
- /** Captured standard output. */
13
- stdout: string;
14
- /** Captured standard error. */
15
- stderr: string;
16
- }
17
- /**
18
- * Options for spawning a long-running process.
19
- */
20
- interface SpawnOptions {
21
- /** Resolve when stdout/stderr contains this string. */
22
- waitFor: string;
23
- /** Kill the process after this many milliseconds. */
24
- timeout: number;
25
- }
26
- /**
27
- * Extra environment variables to set for the child process.
28
- * Values are merged on top of process.env. A `null` value unsets the variable.
29
- */
30
- type CommandEnv = Record<string, null | string>;
31
- /**
32
- * Abstract CLI interface for specification runners.
33
- * Implement this to plug in your command execution strategy.
34
- */
35
- interface CommandPort {
36
- /** Execute a CLI command with the given arguments in the given working directory. */
37
- exec(args: string, cwd: string, env?: CommandEnv): Promise<CommandResult>;
38
- /** Spawn a long-running process and wait for a pattern or timeout. */
39
- spawn(args: string, cwd: string, options: SpawnOptions, env?: CommandEnv): Promise<CommandResult>;
40
- }
41
- //#endregion
42
- //#region src/builder/http/server.port.d.ts
43
- /**
44
- * HTTP response returned by a server port, with parsed JSON body.
45
- */
46
- interface ServerResponse {
47
- /** HTTP status code. */
48
- status: number;
49
- /** Parsed JSON response body, or null if parsing failed. */
50
- body: unknown;
51
- /** Response headers as a flat key-value map. */
52
- headers: Record<string, string>;
53
- }
54
- /**
55
- * Abstract server interface for specification runners.
56
- * Integration mode uses an in-process Hono app; E2E mode uses real HTTP via fetch.
57
- */
58
- interface ServerPort {
59
- /** Send an HTTP request and return the parsed response. */
60
- request(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<ServerResponse>;
61
- }
62
- //#endregion
63
- //#region src/builder/common/directory-accessor.d.ts
64
- interface DirectorySnapshotOptions {
65
- /** Extra path segments to ignore (in addition to default: .git, node_modules, etc.). */
66
- ignore?: string[];
67
- /**
68
- * Force update mode regardless of vitest flags / env vars.
69
- * `true` writes the fixture, `false` always asserts. Defaults to auto-detect.
70
- */
71
- update?: boolean;
72
- }
73
- /**
74
- * Handle to a directory produced by a specification run.
75
- * Supports snapshot-based assertions via {@link toMatchFixture} and file listing via {@link files}.
76
- */
77
- declare class DirectoryAccessor {
78
- private absPath;
79
- private testDir;
80
- constructor(absPath: string, testDir: string);
81
- /**
82
- * Compare the directory tree against `expected/{name}/` (relative to the test file).
83
- * On mismatch, throws with a structured diff. With update mode enabled, the
84
- * fixture is overwritten with the current contents instead.
85
- */
86
- toMatchFixture(name: string, options?: DirectorySnapshotOptions): Promise<void>;
87
- /**
88
- * List all files in the directory (recursive, sorted, ignoring defaults).
89
- * Useful for ad-hoc assertions when you don't want a full snapshot.
90
- */
91
- files(options?: {
92
- ignore?: string[];
93
- }): Promise<string[]>;
94
- }
95
- //#endregion
96
- //#region src/builder/common/response-accessor.d.ts
97
- /** Accessor for an HTTP response body with file-based assertion support. */
98
- declare class ResponseAccessor {
99
- readonly body: unknown;
100
- private testDir;
101
- constructor(body: unknown, testDir: string);
102
- /**
103
- * Assert that the response body matches the JSON in `responses/{file}`.
104
- *
105
- * @example
106
- * result.response.toMatchFile("expected-items.json");
107
- */
108
- toMatchFile(file: string): void;
109
- }
110
- //#endregion
111
- //#region src/builder/common/table-assertion.d.ts
112
- /** Assertion helper for verifying database table contents after a specification run. */
113
- declare class TableAssertion {
114
- private tableName;
115
- private db;
116
- constructor(tableName: string, db: DatabasePort);
117
- /**
118
- * Assert that the table contains exactly the expected rows for the given columns.
119
- *
120
- * @example
121
- * await result.table("users").toMatch({
122
- * columns: ["name", "email"],
123
- * rows: [["Alice", "alice@example.com"]],
124
- * });
125
- */
126
- toMatch(expected: {
127
- columns: string[];
128
- rows: unknown[][];
129
- }): Promise<void>;
130
- /** Assert that the table has zero rows. */
131
- toBeEmpty(): Promise<void>;
132
- }
133
- //#endregion
134
- //#region src/builder/common/result.d.ts
135
- /** Read-only handle to a single file produced by a CLI action. */
136
- interface FileAccessor {
137
- /** The UTF-8 text content. Throws if the file does not exist. */
138
- readonly content: string;
139
- readonly exists: boolean;
140
- }
141
- /**
142
- * The outcome of a single specification run.
143
- * Provides accessors for CLI output, HTTP responses, files, directories, and database tables.
144
- */
145
- declare class SpecificationResult {
146
- private commandResult?;
147
- private config;
148
- private requestInfo?;
149
- private responseData?;
150
- private testDir;
151
- private workDir?;
152
- constructor(options: {
153
- commandResult?: CommandResult;
154
- config: SpecificationConfig;
155
- requestInfo?: {
156
- body?: unknown;
157
- method: string;
158
- path: string;
159
- };
160
- response?: ServerResponse;
161
- testDir: string;
162
- workDir?: string;
163
- });
164
- /** The process exit code. Only available after a CLI action. */
165
- get exitCode(): number;
166
- /** The HTTP response status code. Only available after an HTTP action. */
167
- get status(): number;
168
- /** The captured standard output. Only available after a CLI action. */
169
- get stdout(): string;
170
- /** The captured standard error. Only available after a CLI action. */
171
- get stderr(): string;
172
- /**
173
- * Extract text blocks from stdout that contain a pattern.
174
- * Useful for parsing structured CLI output (linters, compilers).
175
- *
176
- * @example
177
- * expect(result.grep('error.ts')).toContain('no-unused-vars');
178
- */
179
- grep(pattern: string): string;
180
- /** Access the HTTP response body for assertions. Only available after an HTTP action. */
181
- get response(): ResponseAccessor;
182
- /** Access a directory (relative to the working directory) for snapshot assertions. */
183
- directory(path?: string): DirectoryAccessor;
184
- /** Access a single file (relative to the working directory) for content assertions. */
185
- file(path: string): FileAccessor;
186
- /** Access a database table for row-level assertions. */
187
- table(tableName: string, options?: {
188
- service?: string;
189
- }): TableAssertion;
190
- private resolveDatabase;
191
- }
192
- //#endregion
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
- }
199
- /** Adapter configuration passed to the specification runner at setup time. */
200
- interface SpecificationConfig {
201
- command?: CommandPort;
202
- database?: DatabasePort;
203
- databases?: Map<string, DatabasePort>;
204
- fixturesRoot?: string;
205
- jobs?: JobHandle$1[];
206
- server?: ServerPort;
207
- }
208
- /**
209
- * Fluent builder for declaring a single test specification.
210
- *
211
- * Chain setup methods ({@link seed}, {@link fixture}, {@link env}), an action
212
- * ({@link get}, {@link post}, {@link exec}), then call {@link run} to execute
213
- * and receive a {@link SpecificationResult} for assertions.
214
- */
215
- declare class SpecificationBuilder {
216
- private commandArgs;
217
- private commandEnv;
218
- private config;
219
- private fixtures;
220
- private intercepts;
221
- private jobName;
222
- private label;
223
- private mocks;
224
- private projectName;
225
- private request;
226
- private requestHeaders;
227
- private seeds;
228
- private spawnConfig;
229
- private testDir;
230
- constructor(config: SpecificationConfig, testDir: string, label: string);
231
- /**
232
- * Queue a SQL seed file to run before the action.
233
- *
234
- * @example
235
- * spec("creates user").seed("users.sql").exec("list-users").run();
236
- */
237
- seed(file: string, options?: {
238
- service?: string;
239
- }): this;
240
- /** Copy a file or directory from `fixtures/` into the working directory before execution. */
241
- fixture(file: string): this;
242
- /** Copy an entire project fixture from `fixturesRoot` into the working directory. */
243
- project(name: string): this;
244
- /** Register an MSW mock definition file from `mock/` to intercept HTTP calls. */
245
- mock(file: string): this;
246
- /**
247
- * Set environment variables for the CLI process. Merged on top of process.env.
248
- * Use `null` to unset a variable. Multiple calls merge.
249
- *
250
- * The token `$WORKDIR` (in any value) is replaced with the actual working
251
- * directory at run-time — useful for tests that need a fully isolated `HOME`.
252
- *
253
- * @example
254
- * spec("...").env({ HOME: "$WORKDIR", TZ: "UTC" }).exec("status").run();
255
- */
256
- env(env: CommandEnv): this;
257
- /**
258
- * Set HTTP headers for the request. Multiple calls merge.
259
- *
260
- * @example
261
- * spec("french").headers({ 'Accept-Language': 'fr' }).get("/articles").run();
262
- */
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.agent(), http.get(), etc.)
270
- * @param response - What to return: an InterceptResponse object, or a filename
271
- * from `intercepts/` (JSON loaded and auto-wrapped by the trigger).
272
- *
273
- * @example
274
- * // With inline response
275
- * .intercept(openai.agent({...}), openai.reply({ categories: ['TECH'] }))
276
- *
277
- * // With JSON fixture file (loaded from intercepts/ directory)
278
- * .intercept(openai.agent({...}), 'ingest-tech.json')
279
- * .intercept(http.get(url), 'world-news-tech.json')
280
- */
281
- intercept(trigger: InterceptTrigger, response: InterceptResponse | string): this;
282
- /**
283
- * Send a GET request to the server adapter.
284
- *
285
- * @example
286
- * spec("list items").get("/api/items").run();
287
- */
288
- get(path: string): this;
289
- /**
290
- * Send a POST request to the server adapter.
291
- *
292
- * @param bodyFile - Optional JSON file from `requests/` to use as the request body.
293
- * @example
294
- * spec("create item").post("/api/items", "new-item.json").run();
295
- */
296
- post(path: string, bodyFile?: string): this;
297
- /** Send a PUT request to the server adapter. */
298
- put(path: string, bodyFile?: string): this;
299
- /** Send a DELETE request to the server adapter. */
300
- delete(path: string): this;
301
- /**
302
- * Execute a CLI command (or a sequence of commands) in an isolated working directory.
303
- * When an array is passed, commands run sequentially and stop on the first non-zero exit code.
304
- *
305
- * @example
306
- * spec("init project").exec("init --name demo").run();
307
- * spec("multi-step").exec(["init", "build"]).run();
308
- */
309
- exec(args: string | string[]): this;
310
- /** Spawn a long-running CLI process with custom spawn options (e.g. timeout, signal). */
311
- spawn(args: string, options: SpawnOptions): this;
312
- /**
313
- * Execute a named job registered via the app() factory.
314
- *
315
- * @param name - The job name to trigger (must match a registered JobHandle.name).
316
- *
317
- * @example
318
- * spec('pipeline').intercept(openai.chat(), openai.response({...})).job('report-refresh').run();
319
- */
320
- job(name: string): this;
321
- /**
322
- * Execute the specification: run seeds, copy fixtures, then perform the
323
- * configured action (HTTP or CLI).
324
- *
325
- * @returns The result object used for assertions.
326
- * @example
327
- * const result = await spec("test").exec("status").run();
328
- * expect(result.exitCode).toBe(0);
329
- */
330
- run(): Promise<SpecificationResult>;
331
- private resolveEnv;
332
- private prepareWorkDir;
333
- private runHttpAction;
334
- private runJobAction;
335
- private runCliAction;
336
- }
337
- /** Factory function returned by `cli()`, `integration()`, or `e2e()` that starts a new spec. */
338
- type SpecificationRunner = (label: string) => SpecificationBuilder;
339
- /**
340
- * Create a {@link SpecificationRunner} bound to the given adapter configuration.
341
- * The test file directory is auto-detected from the call stack.
342
- */
343
- declare function createSpecificationRunner(config: SpecificationConfig): SpecificationRunner;
344
- //#endregion
345
- //#region src/docker/docker-port.d.ts
346
- /** Abstract interface for interacting with a Docker container (exec, inspect, file I/O). */
347
- interface DockerContainerPort {
348
- /** Execute a command inside the container, return stdout */
349
- exec(cmd: string[]): Promise<string>;
350
- /** Read a file from inside the container */
351
- file(path: string): Promise<{
352
- exists: boolean;
353
- content: string;
354
- }>;
355
- /** Check if container is running */
356
- isRunning(): Promise<boolean>;
357
- /** Get container logs */
358
- logs(tail?: number): Promise<string>;
359
- /** Get full docker inspect JSON */
360
- inspect(): Promise<DockerInspectResult>;
361
- /** Check if a file/directory exists */
362
- exists(path: string): Promise<boolean>;
363
- }
364
- /** Normalized subset of `docker inspect` output for assertion use. */
365
- interface DockerInspectResult {
366
- id: string;
367
- name: string;
368
- state: {
369
- running: boolean;
370
- exitCode: number;
371
- status: string;
372
- };
373
- config: {
374
- image: string;
375
- env: string[];
376
- };
377
- hostConfig: {
378
- memory: number;
379
- cpuQuota: number;
380
- networkMode: string;
381
- mounts: Array<{
382
- source: string;
383
- destination: string;
384
- type: string;
385
- }>;
386
- };
387
- networkSettings: {
388
- networks: Record<string, {
389
- gateway: string;
390
- ipAddress: string;
391
- }>;
392
- };
393
- }
394
- //#endregion
395
- //#region src/docker/docker-assertion.d.ts
396
- /**
397
- * Fluent assertion builder for Docker containers.
398
- * Chain async assertions like `toBeRunning()`, `toHaveFile()`, `toHaveMount()`.
399
- */
400
- declare class DockerAssertion {
401
- private container;
402
- constructor(container: DockerContainerPort);
403
- /** Assert the container is running */
404
- toBeRunning(): Promise<this>;
405
- /** Assert the container is NOT running / doesn't exist */
406
- toNotExist(): Promise<this>;
407
- /** Assert a file exists inside the container */
408
- toHaveFile(path: string, opts?: {
409
- containing?: string;
410
- }): Promise<this>;
411
- /** Assert a file does NOT exist */
412
- toNotHaveFile(path: string): Promise<this>;
413
- /** Assert a directory exists */
414
- toHaveDirectory(path: string): Promise<this>;
415
- /** Assert a mount exists */
416
- toHaveMount(destination: string): Promise<this>;
417
- /** Assert network mode */
418
- toHaveNetwork(mode: string): Promise<this>;
419
- /** Assert memory limit */
420
- toHaveMemoryLimit(bytes: number): Promise<this>;
421
- /** Assert CPU quota */
422
- toHaveCpuQuota(quota: number): Promise<this>;
423
- /** Execute a command and return output for custom assertions */
424
- exec(cmd: string[]): Promise<string>;
425
- /** Read a file for custom assertions */
426
- readFile(path: string): Promise<string>;
427
- /** Get logs for custom assertions */
428
- getLogs(tail?: number): Promise<string>;
429
- }
430
- //#endregion
431
- //#region src/infra/orchestrator.d.ts
432
- interface OrchestratorOptions {
433
- services: ServiceHandle[];
434
- mode: 'e2e' | 'integration';
435
- root?: string;
436
- /** Compose project name — used for per-worker stack isolation. */
437
- projectName?: string;
438
- }
439
- /**
440
- * Orchestrator for test infrastructure.
441
- * Integration: starts services via testcontainers.
442
- * E2E: runs full docker compose up.
443
- */
444
- declare class Orchestrator {
445
- private services;
446
- private mode;
447
- private root;
448
- private projectName;
449
- private running;
450
- private composeStack;
451
- private composeHandles;
452
- private started;
453
- constructor(options: OrchestratorOptions);
454
- /**
455
- * Start declared services via testcontainers (integration mode).
456
- * Phase 1: start all containers in parallel (the slow part).
457
- * Phase 2: wire connections, healthcheck, and init sequentially (fast).
458
- */
459
- start(): Promise<void>;
460
- /**
461
- * Stop testcontainers (integration mode).
462
- */
463
- stop(): Promise<void>;
464
- /**
465
- * Start full docker compose stack (e2e mode).
466
- * Auto-detects infra services and creates handles for them.
467
- */
468
- startCompose(): Promise<void>;
469
- /**
470
- * Stop docker compose stack (e2e mode).
471
- */
472
- stopCompose(): Promise<void>;
473
- /**
474
- * Get a database service by compose name, or the first one if no name given.
475
- */
476
- getDatabase(serviceName?: string): DatabasePort | null;
477
- /**
478
- * Get all database services keyed by compose name.
479
- */
480
- getDatabases(): Map<string, DatabasePort>;
481
- /**
482
- * Get app URL from compose (e2e mode).
483
- */
484
- getAppUrl(): null | string;
485
- }
486
- //#endregion
487
- //#region src/spec/targets.d.ts
488
- /** Any object with a request method compatible with Hono's app.request(). */
489
- type HonoApp$1 = {
490
- request: (path: string, init?: RequestInit) => Promise<Response> | Response;
491
- };
492
- /** A named job that can be triggered via .job(). */
493
- interface JobHandle {
494
- name: string;
495
- execute: () => Promise<void>;
496
- }
497
- /** Services map passed to the app factory after infrastructure starts. */
498
- type AppServices = Record<string, ServiceHandle>;
499
- /**
500
- * Return value from the app() factory. Either a bare server (backward compat)
501
- * or an object with server + jobs for job-based testing.
502
- */
503
- type AppFactoryResult = HonoApp$1 | {
504
- server: HonoApp$1;
505
- jobs: JobHandle[];
506
- };
507
- /** In-process Hono app target. Created by {@link app}. */
508
- interface AppTarget {
509
- readonly kind: 'app';
510
- readonly factory: (services: AppServices) => AppFactoryResult;
511
- }
512
- /** Docker compose stack target. Created by {@link stack}. */
513
- interface StackTarget {
514
- readonly kind: 'stack';
515
- readonly root: string;
516
- }
517
- /** CLI command target. Created by {@link command}. */
518
- interface CommandTarget {
519
- readonly kind: 'command';
520
- readonly bin: string;
521
- }
522
- /** Any target that produces an HTTP interface (app or stack). */
523
- type HttpTarget = AppTarget | StackTarget;
524
- /** Any valid spec target. */
525
- type SpecTarget = AppTarget | CommandTarget | StackTarget;
526
- /**
527
- * Test against an in-process Hono app. The factory receives started services
528
- * so you can wire connection strings into your app/DI container.
529
- *
530
- * @param factory - Function that receives services and returns a Hono app instance.
531
- *
532
- * @example
533
- * const db = postgres({ compose: 'db' });
534
- * await spec(
535
- * app((services) => createApp({ databaseUrl: services.db.connectionString })),
536
- * { services: [db] },
537
- * );
538
- */
539
- declare function app(factory: (services: AppServices) => HonoApp$1): AppTarget;
540
- /**
541
- * Test against a full docker compose stack. The stack is started with
542
- * `docker compose up` and real HTTP requests are sent to the app service.
543
- *
544
- * @param root - Project root containing `docker/compose.test.yaml`.
545
- *
546
- * @example
547
- * await spec(stack('../../'));
548
- */
549
- declare function stack(root: string): StackTarget;
550
- /**
551
- * Test a CLI binary. Each spec runs in a fresh temp directory.
552
- *
553
- * @param bin - Path to the CLI binary or command name (resolved from node_modules/.bin or PATH).
554
- *
555
- * @example
556
- * await spec(command('my-cli'), { root: '../fixtures' });
557
- */
558
- declare function command(bin: string): CommandTarget;
559
- //#endregion
560
- //#region src/spec/spec.d.ts
561
- /** Shared options for all spec targets. */
562
- interface SpecOptions {
563
- /** Project root for fixture lookup and compose detection (relative paths supported). */
564
- root?: string;
565
- /** Infrastructure services to start via testcontainers. */
566
- services?: ServiceHandle[];
567
- }
568
- /** A specification runner with teardown support and orchestrator access. */
569
- interface SpecRunner {
570
- /** The function to create individual specs: `runner('label').get('/path').run()`. */
571
- (label: string): SpecificationBuilder;
572
- /** Stop all infrastructure started by this runner. */
573
- cleanup: () => Promise<void>;
574
- /**
575
- * Get a Docker assertion builder for a running container.
576
- *
577
- * @example
578
- * await runner.docker('my-container').toBeRunning();
579
- */
580
- docker: (containerId: string) => DockerAssertion;
581
- /** The orchestrator managing the test infrastructure lifecycle. */
582
- orchestrator: Orchestrator;
583
- }
584
- /**
585
- * Create a specification runner for the given target.
586
- *
587
- * @param target - What to test against: {@link app}, {@link stack}, or {@link command}.
588
- * @param options - Shared options: root directory, infrastructure services.
589
- *
590
- * @example
591
- * // HTTP — in-process app with testcontainers
592
- * const s = await spec(app(() => createApp(db)), { services: [db] });
593
- *
594
- * // HTTP — full docker compose stack
595
- * const s = await spec(stack('../../'));
596
- *
597
- * // CLI — command binary
598
- * const s = await spec(command('my-cli'), { root: '../fixtures' });
599
- */
600
- declare function spec(target: SpecTarget, options?: SpecOptions): Promise<SpecRunner>;
601
- //#endregion
602
- //#region src/infra/ports/container.port.d.ts
603
- /**
604
- * Abstract container interface.
605
- * Represents a running service (database, cache, etc.)
606
- */
607
- interface ContainerPort {
608
- /** Start the container and wait until ready. */
609
- start(): Promise<void>;
610
- /** Stop and remove the container. */
611
- stop(): Promise<void>;
612
- /** Get the mapped host port for a container port. */
613
- getMappedPort(containerPort: number): number;
614
- /** Get the host to connect to. */
615
- getHost(): string;
616
- /** Get a full connection string for this service. */
617
- getConnectionString(): string;
618
- /** Get container logs (stdout + stderr). */
619
- getLogs(): Promise<string>;
620
- }
621
- //#endregion
622
- //#region src/builder/cli/adapters/exec.adapter.d.ts
623
- /**
624
- * Executes CLI commands via Node.js child_process.
625
- * Uses `execSync` for one-shot commands and `spawn` for long-running processes.
626
- * Used by the `cli()` specification runner.
627
- */
628
- declare class ExecAdapter implements CommandPort {
629
- private command;
630
- constructor(command: string);
631
- exec(args: string, cwd: string, extraEnv?: CommandEnv): Promise<CommandResult>;
632
- spawn(args: string, cwd: string, options: SpawnOptions, extraEnv?: CommandEnv): Promise<CommandResult>;
633
- }
634
- //#endregion
635
- //#region src/builder/http/adapters/fetch.adapter.d.ts
636
- /**
637
- * Server adapter that sends real HTTP requests via the Fetch API.
638
- * Used by the `e2e()` specification runner to hit a live server.
639
- */
640
- declare class FetchAdapter implements ServerPort {
641
- private baseUrl;
642
- constructor(url: string);
643
- request(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<ServerResponse>;
644
- }
645
- //#endregion
646
- //#region src/builder/http/adapters/hono.adapter.d.ts
647
- /**
648
- * Server adapter that dispatches requests in-process through a Hono app instance.
649
- * Used by the `integration()` specification runner -- no network overhead.
650
- */
651
- declare class HonoAdapter implements ServerPort {
652
- private app;
653
- constructor(app: {
654
- request: (path: string, init?: RequestInit) => Promise<Response> | Response;
655
- });
656
- request(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<ServerResponse>;
657
- }
658
- //#endregion
659
- //#region src/spec/legacy-integration.d.ts
660
- type HonoApp = {
661
- fetch: (...args: any[]) => any;
662
- request: (path: string, init?: RequestInit) => Promise<Response> | Response;
663
- };
664
- interface IntegrationOptions {
665
- /** Factory that returns a Hono app — called after services start. */
666
- app: () => HonoApp;
667
- /** Project root for compose detection (relative paths supported). */
668
- root?: string;
669
- /** Declared services — started via testcontainers. */
670
- services: ServiceHandle[];
671
- }
672
- /** A specification runner that also exposes teardown and the underlying orchestrator. */
673
- interface SpecificationRunnerWithCleanup extends SpecificationRunner {
674
- /** Stop all infrastructure containers started by this runner. */
675
- cleanup: () => Promise<void>;
676
- /** The orchestrator managing the test infrastructure lifecycle. */
677
- orchestrator: Orchestrator;
678
- }
679
- /**
680
- * Create an integration specification runner.
681
- * Starts infra containers via testcontainers, app runs in-process.
682
- */
683
- declare function integration(options: IntegrationOptions): Promise<SpecificationRunnerWithCleanup>;
684
- //#endregion
685
- //#region src/spec/legacy-cli.d.ts
686
- interface CliOptions {
687
- /** CLI command to run (resolved from node_modules/.bin or PATH). */
688
- command: string;
689
- /** Project root — base dir for .project() fixture lookup (relative paths supported). */
690
- root?: string;
691
- /** Optional infrastructure services (started via testcontainers). */
692
- services?: ServiceHandle[];
693
- }
694
- /**
695
- * Create a CLI specification runner.
696
- * Runs CLI commands against fixture projects. Optionally starts infrastructure.
697
- */
698
- declare function cli(options: CliOptions): Promise<SpecificationRunnerWithCleanup>;
699
- //#endregion
700
- //#region src/spec/legacy-e2e.d.ts
701
- interface E2eOptions {
702
- /** Project root — must contain docker/compose.test.yaml. */
703
- root?: string;
704
- }
705
- /**
706
- * Create an E2E specification runner.
707
- * Starts full docker compose stack. App URL and database auto-detected.
708
- */
709
- declare function e2e(options?: E2eOptions): Promise<SpecificationRunnerWithCleanup>;
710
- //#endregion
711
- //#region src/builder/common/grep.d.ts
712
- /**
713
- * Extract text blocks from output that contain a pattern.
714
- * Splits by blank lines (how linter/compiler output is structured),
715
- * returns only blocks matching the pattern.
716
- *
717
- * @example
718
- * expect(grep(result.stdout, "unused-var.ts")).toContain("no-unused-vars")
719
- * expect(grep(result.stdout, "valid/sorted.ts")).not.toContain("sort-imports")
720
- */
721
- declare function grep(output: string, pattern: string): string;
722
- //#endregion
723
- //#region src/builder/common/reporter.d.ts
724
- /** Strip ANSI escape codes from a string. */
725
- declare function stripAnsi(str: string): string;
726
- /** Strip ANSI codes and replace volatile tokens (ports, durations) with placeholders. */
727
- declare function normalizeOutput(str: string): string;
728
- //#endregion
729
- //#region src/docker/docker-adapter.d.ts
730
- /** Create a {@link DockerContainerPort} bound to an existing container by ID. */
731
- declare function dockerContainer(containerId: string): DockerContainerPort;
732
- //#endregion
733
- 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 };
734
- //# sourceMappingURL=index.d.cts.map