Reworks the test-db module into explicit primitives: ensureTemplateDatabase (dropped/recreated + built once per schema hash change, cached in .cache/testdb-template.json), cloneTemplateInto, dropDatabaseIfPresent and dropStaleWorkerDatabases. bootstrapTestDatabase() keeps its export but is re-expressed as guarantee-template + fresh clone for the serial databases (vitest pre-stage-2, Playwright), so repeated runs skip drizzle push entirely. The legacy truncate+push flow survives verbatim as bootstrapSerialDatabase for the TEST_DATABASE_URI bisect mode. Nothing may connect to the template while clones run (loud invariant comment).
12 lines
506 B
TypeScript
12 lines
506 B
TypeScript
import { bootstrapTestDatabase } from "./test-db";
|
|
|
|
/**
|
|
* Vitest global setup: point the suite at the dedicated test database and
|
|
* leave it in a known state (ensured, migrated, truncated, seeded, sequences
|
|
* repaired) before any test file loads. Stage 2 rewires this entry point to
|
|
* the template + per-fork clone lifecycle; until then it bootstraps the one
|
|
* serial test database exactly as before.
|
|
*/
|
|
export default async function globalSetup(): Promise<void> {
|
|
await bootstrapTestDatabase();
|
|
}
|