@danceroutine/tango-testing 0.1.0 → 1.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.
- package/LICENSE +21 -0
- package/README.md +85 -0
- package/dist/aDBClient-W6eXsK3X.js +21 -0
- package/dist/aDBClient-W6eXsK3X.js.map +1 -0
- package/dist/assertions/index.js +1 -1
- package/dist/{assertions-CN6KxXhH.js → assertions-CCFZ53Y-.js} +1 -1
- package/dist/assertions-CCFZ53Y-.js.map +1 -0
- package/dist/express/anExpressRequest.d.ts +24 -0
- package/dist/express/anExpressResponse.d.ts +9 -0
- package/dist/express/index.d.ts +3 -0
- package/dist/express/index.js +3 -0
- package/dist/express-Czpfz_Ay.js +68 -0
- package/dist/express-Czpfz_Ay.js.map +1 -0
- package/dist/factories/ModelDataFactory.d.ts +16 -1
- package/dist/factories/index.js +1 -1
- package/dist/{factories-CCAZ6E-g.js → factories-Cl_CAzbj.js} +19 -4
- package/dist/factories-Cl_CAzbj.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +8 -11
- package/dist/integration/HarnessStrategyRegistry.d.ts +15 -0
- package/dist/integration/TestHarness.d.ts +23 -2
- package/dist/integration/anIntegrationHarness.d.ts +5 -0
- package/dist/integration/config.d.ts +4 -0
- package/dist/integration/conformance/index.d.ts +1 -0
- package/dist/integration/conformance/runDialectConformanceSuite.d.ts +11 -0
- package/dist/integration/domain/Dialect.d.ts +5 -4
- package/dist/integration/domain/ResetMode.d.ts +6 -5
- package/dist/integration/index.d.ts +8 -1
- package/dist/integration/index.js +3 -2
- package/dist/integration/migrations/ApplyAndVerifyMigrations.d.ts +3 -0
- package/dist/integration/migrations/AssertMigrationPlan.d.ts +3 -0
- package/dist/integration/migrations/IntrospectSchema.d.ts +3 -0
- package/dist/integration/orm/createQuerySetFixture.d.ts +10 -0
- package/dist/integration/orm/expectQueryResult.d.ts +4 -0
- package/dist/integration/orm/index.d.ts +6 -0
- package/dist/integration/orm/seedTable.d.ts +5 -0
- package/dist/integration/runtime/aTangoConfig.d.ts +8 -0
- package/dist/integration/runtime/index.d.ts +6 -0
- package/dist/integration/runtime/setupTestTangoRuntime.d.ts +6 -0
- package/dist/integration/smoke/AppProcessHarness.d.ts +83 -0
- package/dist/integration/smoke/index.d.ts +4 -0
- package/dist/integration/strategies/PostgresHarnessStrategy.d.ts +9 -0
- package/dist/integration/strategies/SqliteHarnessStrategy.d.ts +9 -0
- package/dist/integration-BrJw6NzG.js +747 -0
- package/dist/integration-BrJw6NzG.js.map +1 -0
- package/dist/mocks/DBClient.d.ts +1 -9
- package/dist/mocks/MockQuerySetResult.d.ts +5 -12
- package/dist/mocks/aDBClient.d.ts +21 -0
- package/dist/mocks/aManager.d.ts +17 -0
- package/dist/mocks/aQueryExecutor.d.ts +14 -0
- package/dist/mocks/aQueryResult.d.ts +5 -0
- package/dist/mocks/aQuerySet.d.ts +8 -0
- package/dist/mocks/aRequestContext.d.ts +22 -0
- package/dist/mocks/index.d.ts +9 -4
- package/dist/mocks/index.js +4 -6
- package/dist/mocks-BkwkXQQt.js +136 -0
- package/dist/mocks-BkwkXQQt.js.map +1 -0
- package/dist/vitest/index.js +3 -2
- package/dist/vitest/registerVitestTango.d.ts +3 -3
- package/dist/{vitest-PxMJue7R.js → vitest-37qN8D93.js} +4 -4
- package/dist/vitest-37qN8D93.js.map +1 -0
- package/package.json +81 -68
- package/dist/assertions/assertions.js +0 -8
- package/dist/assertions-CN6KxXhH.js.map +0 -1
- package/dist/factories/ModelDataFactory.js +0 -33
- package/dist/factories-CCAZ6E-g.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integration/orm.d.ts +0 -9
- package/dist/integration/orm.js +0 -39
- package/dist/integration/strategies/PostgresHarnessStrategy.js +0 -95
- package/dist/integration-CDdpboYz.js +0 -378
- package/dist/integration-CDdpboYz.js.map +0 -1
- package/dist/mocks/DBClient.js +0 -1
- package/dist/mocks/MockQuerySetResult.js +0 -1
- package/dist/mocks/RepositoryLike.d.ts +0 -12
- package/dist/mocks/RepositoryLike.js +0 -1
- package/dist/mocks/aMockDBClient.d.ts +0 -2
- package/dist/mocks/aMockDBClient.js +0 -13
- package/dist/mocks/aMockQuerySet.d.ts +0 -2
- package/dist/mocks/aMockQuerySet.js +0 -15
- package/dist/mocks/aMockRepository.d.ts +0 -2
- package/dist/mocks/aMockRepository.js +0 -20
- package/dist/mocks/types.d.ts +0 -33
- package/dist/mocks-qo-1vCez.js +0 -72
- package/dist/mocks-qo-1vCez.js.map +0 -1
- package/dist/version.d.ts +0 -1
- package/dist/vitest/registerVitestTango.js +0 -90
- package/dist/vitest-PxMJue7R.js.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type TangoRuntime } from '@danceroutine/tango-orm';
|
|
2
|
+
import { type TestTangoConfigOptions } from './aTangoConfig';
|
|
3
|
+
/**
|
|
4
|
+
* Reset and initialize the process-default Tango runtime for tests.
|
|
5
|
+
*/
|
|
6
|
+
export declare function setupTestTangoRuntime(options?: TestTangoConfigOptions): Promise<TangoRuntime>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export interface AppProcessHarnessOptions {
|
|
3
|
+
command: string;
|
|
4
|
+
args?: string[];
|
|
5
|
+
cwd?: string;
|
|
6
|
+
env?: Record<string, string | undefined>;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
readyPath?: string;
|
|
9
|
+
readyTimeoutMs?: number;
|
|
10
|
+
readyIntervalMs?: number;
|
|
11
|
+
stopTimeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
type FetchLike = typeof fetch;
|
|
14
|
+
type ProcessHarnessOutputStream = {
|
|
15
|
+
on(eventName: 'data', listener: (chunk: unknown) => void): unknown;
|
|
16
|
+
};
|
|
17
|
+
type ProcessHarnessChild = {
|
|
18
|
+
exitCode: number | null;
|
|
19
|
+
killed: boolean;
|
|
20
|
+
kill(signal?: NodeJS.Signals): boolean;
|
|
21
|
+
off(eventName: 'exit', listener: () => void): unknown;
|
|
22
|
+
once(eventName: 'exit', listener: () => void): unknown;
|
|
23
|
+
stdout?: ProcessHarnessOutputStream | null;
|
|
24
|
+
stderr?: ProcessHarnessOutputStream | null;
|
|
25
|
+
};
|
|
26
|
+
interface AppProcessHarnessDeps {
|
|
27
|
+
spawnProcess: (command: string, args?: readonly string[], options?: Parameters<typeof spawn>[2]) => ProcessHarnessChild;
|
|
28
|
+
fetchImpl: FetchLike;
|
|
29
|
+
sleep: (ms: number) => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Lightweight process harness for end-to-end smoke tests that need a real app process.
|
|
33
|
+
*/
|
|
34
|
+
export declare class AppProcessHarness {
|
|
35
|
+
static readonly BRAND: "tango.testing.app_process_harness";
|
|
36
|
+
readonly __tangoBrand: typeof AppProcessHarness.BRAND;
|
|
37
|
+
private readonly child;
|
|
38
|
+
private readonly baseUrl;
|
|
39
|
+
private readonly readyUrl;
|
|
40
|
+
private readonly readyTimeoutMs;
|
|
41
|
+
private readonly readyIntervalMs;
|
|
42
|
+
private readonly stopTimeoutMs;
|
|
43
|
+
private readonly deps;
|
|
44
|
+
private stopped;
|
|
45
|
+
private stdoutBuffer;
|
|
46
|
+
private stderrBuffer;
|
|
47
|
+
private constructor();
|
|
48
|
+
/**
|
|
49
|
+
* Narrow an unknown value to the smoke-test harness that owns a child process.
|
|
50
|
+
*/
|
|
51
|
+
static isAppProcessHarness(value: unknown): value is AppProcessHarness;
|
|
52
|
+
/**
|
|
53
|
+
* Spawn the target process and wait until its readiness endpoint responds successfully.
|
|
54
|
+
*/
|
|
55
|
+
static start(options: AppProcessHarnessOptions, deps?: Partial<AppProcessHarnessDeps>): Promise<AppProcessHarness>;
|
|
56
|
+
/**
|
|
57
|
+
* Return the buffered stdout log for recent process output.
|
|
58
|
+
*/
|
|
59
|
+
getStdoutLog(): string;
|
|
60
|
+
/**
|
|
61
|
+
* Return the buffered stderr log for recent process output.
|
|
62
|
+
*/
|
|
63
|
+
getStderrLog(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Return stdout and stderr in a single formatted string for debugging failures.
|
|
66
|
+
*/
|
|
67
|
+
getCombinedLog(): string;
|
|
68
|
+
/**
|
|
69
|
+
* Issue an HTTP request against the managed application process.
|
|
70
|
+
*/
|
|
71
|
+
request(path: string, init?: RequestInit): Promise<Response>;
|
|
72
|
+
/**
|
|
73
|
+
* Assert an HTTP response status and include process logs when it mismatches.
|
|
74
|
+
*/
|
|
75
|
+
assertResponseStatus(response: Response, expectedStatus: number, label: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Stop the managed process, escalating from SIGTERM to SIGKILL when necessary.
|
|
78
|
+
*/
|
|
79
|
+
stop(): Promise<void>;
|
|
80
|
+
private waitForReady;
|
|
81
|
+
private waitForExit;
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { Dialect, type DialectTestCapabilities, type HarnessOptions, type HarnessStrategy, type IntegrationHarness } from '../domain';
|
|
2
|
+
/**
|
|
3
|
+
* Harness strategy for PostgreSQL-backed integration tests.
|
|
4
|
+
*/
|
|
2
5
|
export declare class PostgresHarnessStrategy implements HarnessStrategy {
|
|
3
6
|
static readonly BRAND: "tango.testing.postgres_harness_strategy";
|
|
4
7
|
readonly __tangoBrand: typeof PostgresHarnessStrategy.BRAND;
|
|
5
8
|
readonly dialect: Dialect;
|
|
6
9
|
readonly capabilities: DialectTestCapabilities;
|
|
10
|
+
/**
|
|
11
|
+
* Narrow an unknown value to the PostgreSQL integration harness strategy.
|
|
12
|
+
*/
|
|
7
13
|
static isPostgresHarnessStrategy(value: unknown): value is PostgresHarnessStrategy;
|
|
8
14
|
private static buildSchemaName;
|
|
15
|
+
/**
|
|
16
|
+
* Create a configured Postgres integration harness instance.
|
|
17
|
+
*/
|
|
9
18
|
create(options?: HarnessOptions): Promise<IntegrationHarness>;
|
|
10
19
|
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { Dialect, type DialectTestCapabilities, type HarnessOptions, type HarnessStrategy, type IntegrationHarness } from '../domain';
|
|
2
|
+
/**
|
|
3
|
+
* Harness strategy for SQLite-backed integration tests.
|
|
4
|
+
*/
|
|
2
5
|
export declare class SqliteHarnessStrategy implements HarnessStrategy {
|
|
3
6
|
static readonly BRAND: "tango.testing.sqlite_harness_strategy";
|
|
4
7
|
readonly __tangoBrand: typeof SqliteHarnessStrategy.BRAND;
|
|
5
8
|
readonly dialect: Dialect;
|
|
6
9
|
readonly capabilities: DialectTestCapabilities;
|
|
10
|
+
/**
|
|
11
|
+
* Narrow an unknown value to the SQLite integration harness strategy.
|
|
12
|
+
*/
|
|
7
13
|
static isSqliteHarnessStrategy(value: unknown): value is SqliteHarnessStrategy;
|
|
8
14
|
private static dropAllTables;
|
|
15
|
+
/**
|
|
16
|
+
* Create a configured SQLite integration harness instance.
|
|
17
|
+
*/
|
|
9
18
|
create(options?: HarnessOptions): Promise<IntegrationHarness>;
|
|
10
19
|
}
|