diff --git a/vitest.config.ts b/vitest.config.ts index ad09a1b..c30412e 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -10,5 +10,18 @@ export default defineConfig({ test: { environment: "node", setupFiles: ["./tests/setup.ts"], + // Each test file spins up its own throwaway Postgres database by + // mutating process.env.DATABASE_URL in tests/setup.ts's beforeAll (see + // that file). That per-file DB switch is not safe under Vitest's default + // parallel file execution: two files' beforeAll/query timing can + // interleave such that both end up issuing real queries against the + // same throwaway DB (confirmed empirically once Request gained a real + // FK to Employee — tests/employees.test.ts and tests/requests.test.ts + // started intermittently deleting/reading each other's rows, causing + // spurious FK-violation and row-count failures that disappear when run + // sequentially). Disabling file parallelism trades a bit of wall-clock + // test time for correctness — each file's throwaway DB is now genuinely + // private for the duration of that file's run. + fileParallelism: false, }, });