import { defineConfig } from "vitest/config"; import path from "node:path"; export default defineConfig({ resolve: { alias: { "@": path.resolve(__dirname, "./src"), }, }, 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, }, });