@jterrazz/test 5.1.0 → 5.3.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.d.cts CHANGED
@@ -1,17 +1,6 @@
1
1
  import { DeepMockProxy } from "vitest-mock-extended";
2
2
 
3
- //#region src/mocking/mock-of-date.d.ts
4
- interface MockDatePort {
5
- reset: () => void;
6
- set: (date: Date | number | string) => void;
7
- }
8
- declare const mockOfDate: MockDatePort;
9
- //#endregion
10
- //#region src/mocking/mock-of.d.ts
11
- type MockPort = <T>() => DeepMockProxy<T>;
12
- declare const mockOf: MockPort;
13
- //#endregion
14
- //#region src/specification/ports/database.port.d.ts
3
+ //#region src/ports/database.port.d.ts
15
4
  /**
16
5
  * Abstract database interface for specification runners.
17
6
  * Implement this to plug in your database stack.
@@ -25,7 +14,7 @@ interface DatabasePort {
25
14
  reset(): Promise<void>;
26
15
  }
27
16
  //#endregion
28
- //#region src/infrastructure/services/service.port.d.ts
17
+ //#region src/ports/service.port.d.ts
29
18
  /**
30
19
  * A service handle — returned by factory functions like postgres(), redis().
31
20
  * Mutable: connectionString is populated after the orchestrator starts containers.
@@ -57,60 +46,7 @@ interface ServiceHandle {
57
46
  reset(): Promise<void>;
58
47
  }
59
48
  //#endregion
60
- //#region src/infrastructure/orchestrator.d.ts
61
- interface OrchestratorOptions {
62
- services: ServiceHandle[];
63
- mode: "e2e" | "integration";
64
- root?: string;
65
- }
66
- /**
67
- * Orchestrator for test infrastructure.
68
- * Integration: starts services via testcontainers.
69
- * E2E: runs full docker compose up.
70
- */
71
- declare class Orchestrator {
72
- private services;
73
- private mode;
74
- private root;
75
- private running;
76
- private composeStack;
77
- private composeHandles;
78
- private started;
79
- constructor(options: OrchestratorOptions);
80
- /**
81
- * Start declared services via testcontainers (integration mode).
82
- * Phase 1: start all containers in parallel (the slow part).
83
- * Phase 2: wire connections, healthcheck, and init sequentially (fast).
84
- */
85
- start(): Promise<void>;
86
- /**
87
- * Stop testcontainers (integration mode).
88
- */
89
- stop(): Promise<void>;
90
- /**
91
- * Start full docker compose stack (e2e mode).
92
- * Auto-detects infra services and creates handles for them.
93
- */
94
- startCompose(): Promise<void>;
95
- /**
96
- * Stop docker compose stack (e2e mode).
97
- */
98
- stopCompose(): Promise<void>;
99
- /**
100
- * Get a database service by compose name, or the first one if no name given.
101
- */
102
- getDatabase(serviceName?: string): DatabasePort | null;
103
- /**
104
- * Get all database services keyed by compose name.
105
- */
106
- getDatabases(): Map<string, DatabasePort>;
107
- /**
108
- * Get app URL from compose (e2e mode).
109
- */
110
- getAppUrl(): null | string;
111
- }
112
- //#endregion
113
- //#region src/specification/ports/command.port.d.ts
49
+ //#region src/ports/command.port.d.ts
114
50
  /**
115
51
  * Result of executing a CLI command.
116
52
  */
@@ -144,7 +80,7 @@ interface CommandPort {
144
80
  spawn(args: string, cwd: string, options: SpawnOptions, env?: CommandEnv): Promise<CommandResult>;
145
81
  }
146
82
  //#endregion
147
- //#region src/specification/ports/server.port.d.ts
83
+ //#region src/ports/server.port.d.ts
148
84
  /**
149
85
  * HTTP response returned by a server port.
150
86
  */
@@ -162,28 +98,7 @@ interface ServerPort {
162
98
  request(method: string, path: string, body?: unknown): Promise<ServerResponse>;
163
99
  }
164
100
  //#endregion
165
- //#region src/specification/specification.d.ts
166
- interface SpecificationConfig {
167
- command?: CommandPort;
168
- database?: DatabasePort;
169
- databases?: Map<string, DatabasePort>;
170
- fixturesRoot?: string;
171
- server?: ServerPort;
172
- }
173
- interface FileAccessor {
174
- readonly content: string;
175
- readonly exists: boolean;
176
- }
177
- declare class TableAssertion {
178
- private tableName;
179
- private db;
180
- constructor(tableName: string, db: DatabasePort);
181
- toMatch(expected: {
182
- columns: string[];
183
- rows: unknown[][];
184
- }): Promise<void>;
185
- toBeEmpty(): Promise<void>;
186
- }
101
+ //#region src/builder/directory-accessor.d.ts
187
102
  interface DirectorySnapshotOptions {
188
103
  /** Extra path segments to ignore (in addition to default: .git, node_modules, etc.). */
189
104
  ignore?: string[];
@@ -211,12 +126,32 @@ declare class DirectoryAccessor {
211
126
  ignore?: string[];
212
127
  }): Promise<string[]>;
213
128
  }
129
+ //#endregion
130
+ //#region src/builder/response-accessor.d.ts
214
131
  declare class ResponseAccessor {
215
132
  readonly body: unknown;
216
133
  private testDir;
217
134
  constructor(body: unknown, testDir: string);
218
135
  toMatchFile(file: string): void;
219
136
  }
137
+ //#endregion
138
+ //#region src/builder/table-assertion.d.ts
139
+ declare class TableAssertion {
140
+ private tableName;
141
+ private db;
142
+ constructor(tableName: string, db: DatabasePort);
143
+ toMatch(expected: {
144
+ columns: string[];
145
+ rows: unknown[][];
146
+ }): Promise<void>;
147
+ toBeEmpty(): Promise<void>;
148
+ }
149
+ //#endregion
150
+ //#region src/builder/specification-result.d.ts
151
+ interface FileAccessor {
152
+ readonly content: string;
153
+ readonly exists: boolean;
154
+ }
220
155
  declare class SpecificationResult {
221
156
  private commandResult?;
222
157
  private config;
@@ -248,6 +183,15 @@ declare class SpecificationResult {
248
183
  }): TableAssertion;
249
184
  private resolveDatabase;
250
185
  }
186
+ //#endregion
187
+ //#region src/builder/specification-builder.d.ts
188
+ interface SpecificationConfig {
189
+ command?: CommandPort;
190
+ database?: DatabasePort;
191
+ databases?: Map<string, DatabasePort>;
192
+ fixturesRoot?: string;
193
+ server?: ServerPort;
194
+ }
251
195
  declare class SpecificationBuilder {
252
196
  private commandArgs;
253
197
  private commandEnv;
@@ -291,8 +235,167 @@ declare class SpecificationBuilder {
291
235
  private runCliAction;
292
236
  }
293
237
  type SpecificationRunner = (label: string) => SpecificationBuilder;
238
+ declare function createSpecificationRunner(config: SpecificationConfig): SpecificationRunner;
239
+ //#endregion
240
+ //#region src/orchestrator/orchestrator.d.ts
241
+ interface OrchestratorOptions {
242
+ services: ServiceHandle[];
243
+ mode: 'e2e' | 'integration';
244
+ root?: string;
245
+ }
246
+ /**
247
+ * Orchestrator for test infrastructure.
248
+ * Integration: starts services via testcontainers.
249
+ * E2E: runs full docker compose up.
250
+ */
251
+ declare class Orchestrator {
252
+ private services;
253
+ private mode;
254
+ private root;
255
+ private running;
256
+ private composeStack;
257
+ private composeHandles;
258
+ private started;
259
+ constructor(options: OrchestratorOptions);
260
+ /**
261
+ * Start declared services via testcontainers (integration mode).
262
+ * Phase 1: start all containers in parallel (the slow part).
263
+ * Phase 2: wire connections, healthcheck, and init sequentially (fast).
264
+ */
265
+ start(): Promise<void>;
266
+ /**
267
+ * Stop testcontainers (integration mode).
268
+ */
269
+ stop(): Promise<void>;
270
+ /**
271
+ * Start full docker compose stack (e2e mode).
272
+ * Auto-detects infra services and creates handles for them.
273
+ */
274
+ startCompose(): Promise<void>;
275
+ /**
276
+ * Stop docker compose stack (e2e mode).
277
+ */
278
+ stopCompose(): Promise<void>;
279
+ /**
280
+ * Get a database service by compose name, or the first one if no name given.
281
+ */
282
+ getDatabase(serviceName?: string): DatabasePort | null;
283
+ /**
284
+ * Get all database services keyed by compose name.
285
+ */
286
+ getDatabases(): Map<string, DatabasePort>;
287
+ /**
288
+ * Get app URL from compose (e2e mode).
289
+ */
290
+ getAppUrl(): null | string;
291
+ }
292
+ //#endregion
293
+ //#region src/runner/integration.d.ts
294
+ type HonoApp = {
295
+ fetch: (...args: any[]) => any;
296
+ request: (path: string, init?: RequestInit) => Promise<Response> | Response;
297
+ };
298
+ interface IntegrationOptions {
299
+ /** Factory that returns a Hono app — called after services start. */
300
+ app: () => HonoApp;
301
+ /** Project root for compose detection (relative paths supported). */
302
+ root?: string;
303
+ /** Declared services — started via testcontainers. */
304
+ services: ServiceHandle[];
305
+ }
306
+ interface SpecificationRunnerWithCleanup extends SpecificationRunner {
307
+ cleanup: () => Promise<void>;
308
+ orchestrator: Orchestrator;
309
+ }
310
+ /**
311
+ * Create an integration specification runner.
312
+ * Starts infra containers via testcontainers, app runs in-process.
313
+ */
314
+ declare function integration(options: IntegrationOptions): Promise<SpecificationRunnerWithCleanup>;
294
315
  //#endregion
295
- //#region src/infrastructure/services/postgres.d.ts
316
+ //#region src/runner/cli.d.ts
317
+ interface CliOptions {
318
+ /** CLI command to run (resolved from node_modules/.bin or PATH). */
319
+ command: string;
320
+ /** Project root — base dir for .project() fixture lookup (relative paths supported). */
321
+ root?: string;
322
+ /** Optional infrastructure services (started via testcontainers). */
323
+ services?: ServiceHandle[];
324
+ }
325
+ /**
326
+ * Create a CLI specification runner.
327
+ * Runs CLI commands against fixture projects. Optionally starts infrastructure.
328
+ */
329
+ declare function cli(options: CliOptions): Promise<SpecificationRunnerWithCleanup>;
330
+ //#endregion
331
+ //#region src/runner/e2e.d.ts
332
+ interface E2eOptions {
333
+ /** Project root — must contain docker/compose.test.yaml. */
334
+ root?: string;
335
+ }
336
+ /**
337
+ * Create an E2E specification runner.
338
+ * Starts full docker compose stack. App URL and database auto-detected.
339
+ */
340
+ declare function e2e(options?: E2eOptions): Promise<SpecificationRunnerWithCleanup>;
341
+ //#endregion
342
+ //#region src/ports/container.port.d.ts
343
+ /**
344
+ * Abstract container interface.
345
+ * Represents a running service (database, cache, etc.)
346
+ */
347
+ interface ContainerPort {
348
+ /** Start the container and wait until ready. */
349
+ start(): Promise<void>;
350
+ /** Stop and remove the container. */
351
+ stop(): Promise<void>;
352
+ /** Get the mapped host port for a container port. */
353
+ getMappedPort(containerPort: number): number;
354
+ /** Get the host to connect to. */
355
+ getHost(): string;
356
+ /** Get a full connection string for this service. */
357
+ getConnectionString(): string;
358
+ /** Get container logs (stdout + stderr). */
359
+ getLogs(): Promise<string>;
360
+ }
361
+ //#endregion
362
+ //#region src/adapters/exec.adapter.d.ts
363
+ /**
364
+ * Executes CLI commands via execSync (blocking) or spawn (long-running).
365
+ * Used by cli() for local command execution.
366
+ */
367
+ declare class ExecAdapter implements CommandPort {
368
+ private command;
369
+ constructor(command: string);
370
+ exec(args: string, cwd: string, extraEnv?: CommandEnv): Promise<CommandResult>;
371
+ spawn(args: string, cwd: string, options: SpawnOptions, extraEnv?: CommandEnv): Promise<CommandResult>;
372
+ }
373
+ //#endregion
374
+ //#region src/adapters/fetch.adapter.d.ts
375
+ /**
376
+ * Server adapter for real HTTP — sends actual fetch requests.
377
+ * Used by e2e() specification runner.
378
+ */
379
+ declare class FetchAdapter implements ServerPort {
380
+ private baseUrl;
381
+ constructor(url: string);
382
+ request(method: string, path: string, body?: unknown): Promise<ServerResponse>;
383
+ }
384
+ //#endregion
385
+ //#region src/adapters/hono.adapter.d.ts
386
+ /**
387
+ * Server adapter for Hono — in-process requests, no real HTTP.
388
+ * Used by integration() specification runner.
389
+ */
390
+ declare class HonoAdapter implements ServerPort {
391
+ private app;
392
+ constructor(app: {
393
+ request: (path: string, init?: RequestInit) => Promise<Response> | Response;
394
+ });
395
+ request(method: string, path: string, body?: unknown): Promise<ServerResponse>;
396
+ }
397
+ //#endregion
398
+ //#region src/adapters/postgres.adapter.d.ts
296
399
  interface PostgresOptions {
297
400
  /** Map to a service in docker-compose.test.yaml. */
298
401
  compose?: string;
@@ -329,7 +432,7 @@ declare class PostgresHandle implements DatabasePort, ServiceHandle {
329
432
  */
330
433
  declare function postgres(options?: PostgresOptions): PostgresHandle;
331
434
  //#endregion
332
- //#region src/infrastructure/services/redis.d.ts
435
+ //#region src/adapters/redis.adapter.d.ts
333
436
  interface RedisOptions {
334
437
  /** Map to a service in docker-compose.test.yaml. */
335
438
  compose?: string;
@@ -360,110 +463,7 @@ declare class RedisHandle implements ServiceHandle {
360
463
  */
361
464
  declare function redis(options?: RedisOptions): RedisHandle;
362
465
  //#endregion
363
- //#region src/specification/adapters/exec.adapter.d.ts
364
- /**
365
- * Executes CLI commands via execSync (blocking) or spawn (long-running).
366
- * Used by cli() for local command execution.
367
- */
368
- declare class ExecAdapter implements CommandPort {
369
- private command;
370
- constructor(command: string);
371
- exec(args: string, cwd: string, extraEnv?: CommandEnv): Promise<CommandResult>;
372
- spawn(args: string, cwd: string, options: SpawnOptions, extraEnv?: CommandEnv): Promise<CommandResult>;
373
- }
374
- //#endregion
375
- //#region src/specification/adapters/fetch.adapter.d.ts
376
- /**
377
- * Server adapter for real HTTP — sends actual fetch requests.
378
- * Used by e2e() specification runner.
379
- */
380
- declare class FetchAdapter implements ServerPort {
381
- private baseUrl;
382
- constructor(url: string);
383
- request(method: string, path: string, body?: unknown): Promise<ServerResponse>;
384
- }
385
- //#endregion
386
- //#region src/specification/adapters/hono.adapter.d.ts
387
- /**
388
- * Server adapter for Hono — in-process requests, no real HTTP.
389
- * Used by integration() specification runner.
390
- */
391
- declare class HonoAdapter implements ServerPort {
392
- private app;
393
- constructor(app: {
394
- request: (path: string, init?: RequestInit) => Promise<Response> | Response;
395
- });
396
- request(method: string, path: string, body?: unknown): Promise<ServerResponse>;
397
- }
398
- //#endregion
399
- //#region src/specification/grep.d.ts
400
- /**
401
- * Extract text blocks from output that contain a pattern.
402
- * Splits by blank lines (how linter/compiler output is structured),
403
- * returns only blocks matching the pattern.
404
- *
405
- * @example
406
- * expect(grep(result.stdout, "unused-var.ts")).toContain("no-unused-vars")
407
- * expect(grep(result.stdout, "valid/sorted.ts")).not.toContain("sort-imports")
408
- */
409
- declare function grep(output: string, pattern: string): string;
410
- //#endregion
411
- //#region src/infrastructure/reporter.d.ts
412
- declare function stripAnsi(str: string): string;
413
- declare function normalizeOutput(str: string): string;
414
- //#endregion
415
- //#region src/specification/index.d.ts
416
- type HonoApp = {
417
- fetch: (...args: any[]) => any;
418
- request: (path: string, init?: RequestInit) => Promise<Response> | Response;
419
- };
420
- interface IntegrationOptions {
421
- /** Factory that returns a Hono app — called after services start. */
422
- app: () => HonoApp;
423
- /** Project root for compose detection (relative paths supported). */
424
- root?: string;
425
- /** Declared services — started via testcontainers. */
426
- services: ServiceHandle[];
427
- }
428
- interface E2eOptions {
429
- /** Project root — must contain docker/compose.test.yaml. */
430
- root?: string;
431
- }
432
- interface CliOptions {
433
- /** CLI command to run (resolved from node_modules/.bin or PATH). */
434
- command: string;
435
- /** Project root — base dir for .project() fixture lookup (relative paths supported). */
436
- root?: string;
437
- /** Optional infrastructure services (started via testcontainers). */
438
- services?: ServiceHandle[];
439
- }
440
- interface SpecificationRunnerWithCleanup extends SpecificationRunner {
441
- cleanup: () => Promise<void>;
442
- orchestrator: Orchestrator;
443
- }
444
- /**
445
- * Create an integration specification runner.
446
- * Starts infra containers via testcontainers, app runs in-process.
447
- */
448
- declare function integration(options: IntegrationOptions): Promise<SpecificationRunnerWithCleanup>;
449
- /**
450
- * Create an E2E specification runner.
451
- * Starts full docker compose stack. App URL and database auto-detected.
452
- */
453
- declare function e2e(options?: E2eOptions): Promise<SpecificationRunnerWithCleanup>;
454
- /**
455
- * Create a CLI specification runner.
456
- * Runs CLI commands against fixture projects. Optionally starts infrastructure.
457
- *
458
- * @example
459
- * export const spec = await cli({
460
- * command: resolve(import.meta.dirname, "../../bin/my-cli.sh"),
461
- * root: "../fixtures",
462
- * });
463
- */
464
- declare function cli(options: CliOptions): Promise<SpecificationRunnerWithCleanup>;
465
- //#endregion
466
- //#region src/infrastructure/docker/docker-port.d.ts
466
+ //#region src/docker/docker-port.d.ts
467
467
  interface DockerContainerPort {
468
468
  /** Execute a command inside the container, return stdout */
469
469
  exec(cmd: string[]): Promise<string>;
@@ -511,11 +511,11 @@ interface DockerInspectResult {
511
511
  };
512
512
  }
513
513
  //#endregion
514
- //#region src/infrastructure/docker/docker-adapter.d.ts
514
+ //#region src/docker/docker-adapter.d.ts
515
515
  /** Create a Docker container port for an existing container */
516
516
  declare function dockerContainer(containerId: string): DockerContainerPort;
517
517
  //#endregion
518
- //#region src/infrastructure/docker/docker-assertion.d.ts
518
+ //#region src/docker/docker-assertion.d.ts
519
519
  /** Fluent assertion builder for Docker containers */
520
520
  declare class DockerAssertion {
521
521
  private container;
@@ -548,5 +548,32 @@ declare class DockerAssertion {
548
548
  getLogs(tail?: number): Promise<string>;
549
549
  }
550
550
  //#endregion
551
- export { type CommandEnv, type CommandPort, type CommandResult, type DatabasePort, type DirectoryAccessor, type DirectorySnapshotOptions, DockerAssertion, type DockerContainerPort, type DockerInspectResult, ExecAdapter, FetchAdapter, HonoAdapter, type MockDatePort, type MockPort, Orchestrator, type ServerPort, type ServerResponse, type SpecificationResult, cli, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, stripAnsi };
551
+ //#region src/utilities/grep.d.ts
552
+ /**
553
+ * Extract text blocks from output that contain a pattern.
554
+ * Splits by blank lines (how linter/compiler output is structured),
555
+ * returns only blocks matching the pattern.
556
+ *
557
+ * @example
558
+ * expect(grep(result.stdout, "unused-var.ts")).toContain("no-unused-vars")
559
+ * expect(grep(result.stdout, "valid/sorted.ts")).not.toContain("sort-imports")
560
+ */
561
+ declare function grep(output: string, pattern: string): string;
562
+ //#endregion
563
+ //#region src/utilities/reporter.d.ts
564
+ declare function stripAnsi(str: string): string;
565
+ declare function normalizeOutput(str: string): string;
566
+ //#endregion
567
+ //#region src/mocking/mock-of-date.d.ts
568
+ interface MockDatePort {
569
+ reset: () => void;
570
+ set: (date: Date | number | string) => void;
571
+ }
572
+ declare const mockOfDate: MockDatePort;
573
+ //#endregion
574
+ //#region src/mocking/mock-of.d.ts
575
+ type MockPort = <T>() => DeepMockProxy<T>;
576
+ declare const mockOf: MockPort;
577
+ //#endregion
578
+ export { type CliOptions, type CommandEnv, type CommandPort, type CommandResult, type ContainerPort, type DatabasePort, DirectoryAccessor, type DirectorySnapshotOptions, DockerAssertion, type DockerContainerPort, type DockerInspectResult, type E2eOptions, ExecAdapter, FetchAdapter, type FileAccessor, HonoAdapter, type IntegrationOptions, type MockDatePort, type MockPort, Orchestrator, type PostgresOptions, type RedisOptions, ResponseAccessor, type ServerPort, type ServerResponse, type ServiceHandle, type SpawnOptions, SpecificationBuilder, type SpecificationConfig, SpecificationResult, type SpecificationRunner, type SpecificationRunnerWithCleanup, TableAssertion, cli, createSpecificationRunner, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, stripAnsi };
552
579
  //# sourceMappingURL=index.d.cts.map