SPB Git

Repository Public

global-db.ts 724 B 13 lines typescript

1// vitest global setup (see vitest.config.ts): one run id for the whole run — every test file derives its database name from2// it (test-db.ts) — and, when the run ends, every database of THIS run is dropped. Nothing is created here:3// a run that touches no database costs nothing, and a machine without PostgreSQL still runs the other tests.4import { dropTestDbs, newRunId, TEST_DB_PREFIX } from './test-db.ts';56export default function setup(): () => Promise<void> {7  const run = newRunId();8  process.env.SPW_TEST_RUN = run;9  return async () => {10    try { await dropTestDbs((name) => name.startsWith(`${TEST_DB_PREFIX}${run}_`)); } catch { /* no PostgreSQL on this machine: nothing was created either */ }11  };12}13
Files main
Menu

Theme