From 9e17853d8977c62f9dc424429fe4fc53fd45f027 Mon Sep 17 00:00:00 2001 From: Lucas Berger Date: Tue, 9 Jun 2026 12:23:13 -0400 Subject: [PATCH] fix(04-02): use fileParallelism:false to prevent DB test race conditions Replaced singleFork:true + sequence config with the simpler fileParallelism:false which correctly serializes test file execution. The previous singleFork approach ran tests from multiple files concurrently within one process, allowing the global afterEach cleanup (test/setup.ts: truncates lists/listShares) to delete rows mid-test in another file, causing intermittent FK violations (ER_DUP_ENTRY, ER_NO_REFERENCED_ROW). fileParallelism:false runs one test file at a time so afterEach cleanup for file A never races with insertions from file B. --- apps/api/vitest.config.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/apps/api/vitest.config.ts b/apps/api/vitest.config.ts index 62d9644..5ca3abf 100644 --- a/apps/api/vitest.config.ts +++ b/apps/api/vitest.config.ts @@ -5,17 +5,10 @@ export default defineConfig({ environment: 'node', globals: true, setupFiles: ['./test/setup.ts'], - // Run test files sequentially so concurrent DB tests do not interfere via - // the shared MariaDB (global afterEach in test/setup.ts truncates list tables - // which causes FK violations if two workers share the DB concurrently). - sequence: { - concurrent: false, - }, - pool: 'forks', - // singleFork: top-level in vitest 4.x (poolOptions removed in v4). - // Runs all test files in one forked process so the shared MariaDB - // teardown (afterEach in test/setup.ts) never races with inserts - // from a concurrent worker. - singleFork: true, + // Disable parallel file execution so concurrent DB tests do not interfere + // via the shared MariaDB. The global afterEach in test/setup.ts truncates + // list tables; running test files in parallel causes FK violations when one + // file's afterEach deletes rows that another file's test is still using. + fileParallelism: false, }, })