feat(tests): enhance test database setup and cleanup for improved isolation and performance

This commit is contained in:
Dries Augustyns
2026-05-22 21:01:03 +02:00
parent 71e2277643
commit 32dd7bba46
5 changed files with 137 additions and 104 deletions
+8 -7
View File
@@ -22,18 +22,19 @@ export default defineConfig({
},
testTimeout: 30000,
hookTimeout: 30000,
// Memory optimization: Run tests in sequence to prevent memory issues
// This is critical for tests that create large datasets
// Each fork is a worker with an isolated Postgres database and Redis db-number
// (see test/setup.ts). That isolation is what lets us run files in parallel
// without the cross-test interference we used to hit with a shared DB.
pool: 'forks',
poolOptions: {
forks: {
singleFork: true, // Run all tests in a single fork to limit memory
// Cap at 4 to stay within Postgres' default max_connections=100
// when each worker uses connection_limit=20.
maxForks: 4,
minForks: 1,
},
},
// Run tests sequentially to avoid database cleanup conflicts
fileParallelism: false,
// Limit concurrent test files to reduce memory pressure
maxConcurrency: 3,
maxConcurrency: 5,
// Only include our test files, not dependency tests
include: [
'apps/**/__tests__/**/*.{test,spec}.{ts,tsx}',