@jterrazz/test 6.0.0 → 6.1.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.
- package/dist/chunk.cjs +28 -0
- package/dist/index.cjs +46 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -12
- package/dist/index.d.ts +14 -12
- package/dist/index.js +41 -18
- package/dist/index.js.map +1 -1
- package/dist/mock-of.cjs +2 -29
- package/dist/mock-of.cjs.map +1 -1
- package/dist/services.cjs +4 -3
- package/dist/services.d.cts +2 -2
- package/dist/services.d.ts +2 -2
- package/dist/services.js +2 -2
- package/dist/{redis.adapter.cjs → sqlite.adapter.cjs} +119 -2
- package/dist/sqlite.adapter.cjs.map +1 -0
- package/dist/{redis.adapter.d.ts → sqlite.adapter.d.cts} +56 -2
- package/dist/{redis.adapter.d.cts → sqlite.adapter.d.ts} +56 -2
- package/dist/{redis.adapter.js → sqlite.adapter.js} +113 -3
- package/dist/sqlite.adapter.js.map +1 -0
- package/package.json +3 -1
- package/dist/redis.adapter.cjs.map +0 -1
- package/dist/redis.adapter.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
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
2
|
import { i as mockOfDate, n as mockOf, r as MockDatePort, t as MockPort } from "./mock-of.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/ports/command.port.d.ts
|
|
@@ -440,18 +440,16 @@ declare class Orchestrator {
|
|
|
440
440
|
}
|
|
441
441
|
//#endregion
|
|
442
442
|
//#region src/runner/targets.d.ts
|
|
443
|
-
/**
|
|
444
|
-
* Target factories for {@link spec}. Each target describes what is being tested
|
|
445
|
-
* and how the specification runner should connect to it.
|
|
446
|
-
*/
|
|
447
443
|
type HonoApp$1 = {
|
|
448
444
|
fetch: (...args: any[]) => any;
|
|
449
445
|
request: (path: string, init?: RequestInit) => Promise<Response> | Response;
|
|
450
446
|
};
|
|
447
|
+
/** Services map passed to the app factory after infrastructure starts. */
|
|
448
|
+
type AppServices = Record<string, ServiceHandle>;
|
|
451
449
|
/** In-process Hono app target. Created by {@link app}. */
|
|
452
450
|
interface AppTarget {
|
|
453
451
|
readonly kind: 'app';
|
|
454
|
-
readonly factory: () => HonoApp$1;
|
|
452
|
+
readonly factory: (services: AppServices) => HonoApp$1;
|
|
455
453
|
}
|
|
456
454
|
/** Docker compose stack target. Created by {@link stack}. */
|
|
457
455
|
interface StackTarget {
|
|
@@ -468,15 +466,19 @@ type HttpTarget = AppTarget | StackTarget;
|
|
|
468
466
|
/** Any valid spec target. */
|
|
469
467
|
type SpecTarget = AppTarget | CommandTarget | StackTarget;
|
|
470
468
|
/**
|
|
471
|
-
* Test against an in-process Hono app.
|
|
472
|
-
*
|
|
469
|
+
* Test against an in-process Hono app. The factory receives started services
|
|
470
|
+
* so you can wire connection strings into your app/DI container.
|
|
473
471
|
*
|
|
474
|
-
* @param factory - Function that returns a Hono app instance
|
|
472
|
+
* @param factory - Function that receives services and returns a Hono app instance.
|
|
475
473
|
*
|
|
476
474
|
* @example
|
|
477
|
-
*
|
|
475
|
+
* const db = postgres({ compose: 'db' });
|
|
476
|
+
* await spec(
|
|
477
|
+
* app((services) => createApp({ databaseUrl: services.db.connectionString })),
|
|
478
|
+
* { services: [db] },
|
|
479
|
+
* );
|
|
478
480
|
*/
|
|
479
|
-
declare function app(factory: () => HonoApp$1): AppTarget;
|
|
481
|
+
declare function app(factory: (services: AppServices) => HonoApp$1): AppTarget;
|
|
480
482
|
/**
|
|
481
483
|
* Test against a full docker compose stack. The stack is started with
|
|
482
484
|
* `docker compose up` and real HTTP requests are sent to the app service.
|
|
@@ -670,5 +672,5 @@ declare function normalizeOutput(str: string): string;
|
|
|
670
672
|
/** Create a {@link DockerContainerPort} bound to an existing container by ID. */
|
|
671
673
|
declare function dockerContainer(containerId: string): DockerContainerPort;
|
|
672
674
|
//#endregion
|
|
673
|
-
export { 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 StackTarget, TableAssertion, app, cli, command, createSpecificationRunner, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, spec, stack, stripAnsi };
|
|
675
|
+
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 };
|
|
674
676
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
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
2
|
import { i as mockOfDate, n as mockOf, r as MockDatePort, t as MockPort } from "./mock-of.js";
|
|
3
3
|
|
|
4
4
|
//#region src/ports/command.port.d.ts
|
|
@@ -440,18 +440,16 @@ declare class Orchestrator {
|
|
|
440
440
|
}
|
|
441
441
|
//#endregion
|
|
442
442
|
//#region src/runner/targets.d.ts
|
|
443
|
-
/**
|
|
444
|
-
* Target factories for {@link spec}. Each target describes what is being tested
|
|
445
|
-
* and how the specification runner should connect to it.
|
|
446
|
-
*/
|
|
447
443
|
type HonoApp$1 = {
|
|
448
444
|
fetch: (...args: any[]) => any;
|
|
449
445
|
request: (path: string, init?: RequestInit) => Promise<Response> | Response;
|
|
450
446
|
};
|
|
447
|
+
/** Services map passed to the app factory after infrastructure starts. */
|
|
448
|
+
type AppServices = Record<string, ServiceHandle>;
|
|
451
449
|
/** In-process Hono app target. Created by {@link app}. */
|
|
452
450
|
interface AppTarget {
|
|
453
451
|
readonly kind: 'app';
|
|
454
|
-
readonly factory: () => HonoApp$1;
|
|
452
|
+
readonly factory: (services: AppServices) => HonoApp$1;
|
|
455
453
|
}
|
|
456
454
|
/** Docker compose stack target. Created by {@link stack}. */
|
|
457
455
|
interface StackTarget {
|
|
@@ -468,15 +466,19 @@ type HttpTarget = AppTarget | StackTarget;
|
|
|
468
466
|
/** Any valid spec target. */
|
|
469
467
|
type SpecTarget = AppTarget | CommandTarget | StackTarget;
|
|
470
468
|
/**
|
|
471
|
-
* Test against an in-process Hono app.
|
|
472
|
-
*
|
|
469
|
+
* Test against an in-process Hono app. The factory receives started services
|
|
470
|
+
* so you can wire connection strings into your app/DI container.
|
|
473
471
|
*
|
|
474
|
-
* @param factory - Function that returns a Hono app instance
|
|
472
|
+
* @param factory - Function that receives services and returns a Hono app instance.
|
|
475
473
|
*
|
|
476
474
|
* @example
|
|
477
|
-
*
|
|
475
|
+
* const db = postgres({ compose: 'db' });
|
|
476
|
+
* await spec(
|
|
477
|
+
* app((services) => createApp({ databaseUrl: services.db.connectionString })),
|
|
478
|
+
* { services: [db] },
|
|
479
|
+
* );
|
|
478
480
|
*/
|
|
479
|
-
declare function app(factory: () => HonoApp$1): AppTarget;
|
|
481
|
+
declare function app(factory: (services: AppServices) => HonoApp$1): AppTarget;
|
|
480
482
|
/**
|
|
481
483
|
* Test against a full docker compose stack. The stack is started with
|
|
482
484
|
* `docker compose up` and real HTTP requests are sent to the app service.
|
|
@@ -670,5 +672,5 @@ declare function normalizeOutput(str: string): string;
|
|
|
670
672
|
/** Create a {@link DockerContainerPort} bound to an existing container by ID. */
|
|
671
673
|
declare function dockerContainer(containerId: string): DockerContainerPort;
|
|
672
674
|
//#endregion
|
|
673
|
-
export { 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 StackTarget, TableAssertion, app, cli, command, createSpecificationRunner, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, spec, stack, stripAnsi };
|
|
675
|
+
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 };
|
|
674
676
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as postgres, t as
|
|
1
|
+
import { n as redis, r as postgres, t as sqlite } from "./sqlite.adapter.js";
|
|
2
2
|
import { n as mockOfDate, t as mockOf } from "./mock-of.js";
|
|
3
3
|
import { execSync, spawn } from "node:child_process";
|
|
4
4
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync } from "node:fs";
|
|
@@ -1210,7 +1210,13 @@ var Orchestrator = class {
|
|
|
1210
1210
|
const composePath = findComposeFile(this.root);
|
|
1211
1211
|
const composeDir = composePath ? dirname(composePath) : this.root;
|
|
1212
1212
|
const composeConfig = composePath ? parseComposeFile(composePath) : null;
|
|
1213
|
-
const
|
|
1213
|
+
const containerServices = [];
|
|
1214
|
+
const embeddedServices = [];
|
|
1215
|
+
for (const handle of this.services) {
|
|
1216
|
+
if (handle.defaultPort === 0) {
|
|
1217
|
+
embeddedServices.push(handle);
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
1214
1220
|
let image = handle.defaultImage;
|
|
1215
1221
|
let env = { ...handle.environment };
|
|
1216
1222
|
if (handle.composeName && composeConfig) {
|
|
@@ -1224,18 +1230,26 @@ var Orchestrator = class {
|
|
|
1224
1230
|
Object.assign(handle.environment, composeService.environment);
|
|
1225
1231
|
}
|
|
1226
1232
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
+
const container = new TestcontainersAdapter({
|
|
1234
|
+
image,
|
|
1235
|
+
port: handle.defaultPort,
|
|
1236
|
+
env
|
|
1237
|
+
});
|
|
1238
|
+
containerServices.push({
|
|
1239
|
+
container,
|
|
1233
1240
|
handle
|
|
1234
|
-
};
|
|
1235
|
-
}
|
|
1236
|
-
await Promise.all(
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
await Promise.all([...containerServices.map(({ container }) => container.start()), ...embeddedServices.map(async (handle) => {
|
|
1244
|
+
await handle.initialize(composeDir);
|
|
1245
|
+
handle.started = true;
|
|
1246
|
+
this.running.push({
|
|
1247
|
+
handle,
|
|
1248
|
+
container: null
|
|
1249
|
+
});
|
|
1250
|
+
})]);
|
|
1237
1251
|
const reports = [];
|
|
1238
|
-
for (const { container, handle } of
|
|
1252
|
+
for (const { container, handle } of containerServices) {
|
|
1239
1253
|
const serviceStartTime = Date.now();
|
|
1240
1254
|
try {
|
|
1241
1255
|
const host = container.getHost();
|
|
@@ -1449,7 +1463,12 @@ async function startApp(target, options) {
|
|
|
1449
1463
|
});
|
|
1450
1464
|
await orchestrator.start();
|
|
1451
1465
|
await acquireIsolation(services);
|
|
1452
|
-
const
|
|
1466
|
+
const servicesMap = {};
|
|
1467
|
+
for (const svc of services) {
|
|
1468
|
+
const key = svc.composeName ?? svc.type;
|
|
1469
|
+
servicesMap[key] = svc;
|
|
1470
|
+
}
|
|
1471
|
+
const honoApp = target.factory(servicesMap);
|
|
1453
1472
|
const database = orchestrator.getDatabase() ?? void 0;
|
|
1454
1473
|
const databases = orchestrator.getDatabases();
|
|
1455
1474
|
const runner = createSpecificationRunner({
|
|
@@ -1525,13 +1544,17 @@ async function startCommand(target, options) {
|
|
|
1525
1544
|
//#endregion
|
|
1526
1545
|
//#region src/runner/targets.ts
|
|
1527
1546
|
/**
|
|
1528
|
-
* Test against an in-process Hono app.
|
|
1529
|
-
*
|
|
1547
|
+
* Test against an in-process Hono app. The factory receives started services
|
|
1548
|
+
* so you can wire connection strings into your app/DI container.
|
|
1530
1549
|
*
|
|
1531
|
-
* @param factory - Function that returns a Hono app instance
|
|
1550
|
+
* @param factory - Function that receives services and returns a Hono app instance.
|
|
1532
1551
|
*
|
|
1533
1552
|
* @example
|
|
1534
|
-
*
|
|
1553
|
+
* const db = postgres({ compose: 'db' });
|
|
1554
|
+
* await spec(
|
|
1555
|
+
* app((services) => createApp({ databaseUrl: services.db.connectionString })),
|
|
1556
|
+
* { services: [db] },
|
|
1557
|
+
* );
|
|
1535
1558
|
*/
|
|
1536
1559
|
function app(factory) {
|
|
1537
1560
|
return {
|
|
@@ -1655,6 +1678,6 @@ async function integration(options) {
|
|
|
1655
1678
|
return runner;
|
|
1656
1679
|
}
|
|
1657
1680
|
//#endregion
|
|
1658
|
-
export { DirectoryAccessor, DockerAssertion, ExecAdapter, FetchAdapter, HonoAdapter, Orchestrator, ResponseAccessor, SpecificationBuilder, SpecificationResult, TableAssertion, app, cli, command, createSpecificationRunner, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, spec, stack, stripAnsi };
|
|
1681
|
+
export { DirectoryAccessor, DockerAssertion, ExecAdapter, FetchAdapter, HonoAdapter, Orchestrator, ResponseAccessor, SpecificationBuilder, SpecificationResult, TableAssertion, app, cli, command, createSpecificationRunner, dockerContainer, e2e, grep, integration, mockOf, mockOfDate, normalizeOutput, postgres, redis, spec, sqlite, stack, stripAnsi };
|
|
1659
1682
|
|
|
1660
1683
|
//# sourceMappingURL=index.js.map
|