The integration suite shares one personal_test database and helpers.resetDB() TRUNCATEs it with CASCADE, which reaches expense_metadata via the transactions FK. With file parallelism on, queries.test.ts and participants.test.ts were truncating rows out from under order-ingestion.test.ts mid-test, so a different set of assertions failed on every run — including I6 (credits), I7 (idempotency) and I11 ([Family]), the three invariants the suite exists to prove. Serialise the files. Suite was reported 31/31 green; observed 29/31 then 28/31 on consecutive runs. Now 31/31 on three consecutive runs.
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
import { readFileSync, existsSync } from "fs";
|
|
import { resolve } from "path";
|
|
|
|
// Load .env.test into process.env HERE, at config-load time.
|
|
// Forked workers inherit the parent process env, so Prisma's singleton
|
|
// will see the test DATABASE_URL when db.ts is first imported.
|
|
const envTestPath = resolve(__dirname, ".env.test");
|
|
if (existsSync(envTestPath)) {
|
|
for (const line of readFileSync(envTestPath, "utf-8").split("\n")) {
|
|
const m = line.match(/^([^#=]+)=(.*)/);
|
|
if (m) process.env[m[1].trim()] = m[2].trim();
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [tsconfigPaths()],
|
|
test: {
|
|
environment: "node",
|
|
include: ["src/__tests__/integration/**/*.test.ts"],
|
|
pool: "forks",
|
|
// Every integration file shares the one `personal_test` database, and
|
|
// helpers.resetDB() TRUNCATEs it (CASCADE reaches expense_metadata).
|
|
// Run files one at a time so a sibling's reset cannot delete rows another
|
|
// file just inserted — that raced non-deterministically across I6/I7/I11.
|
|
fileParallelism: false,
|
|
},
|
|
});
|