Some checks failed
Agent PR Ready + auto-merge / ready-automerge (pull_request) Has been skipped
CI (PR) / docs-guards (pull_request) Successful in 6s
CI (PR) / plans-only-closes (pull_request) Successful in 6s
CI (PR) / scope (pull_request) Successful in 31s
CI (PR) / lint (pull_request) Successful in 40s
CI (PR) / format (pull_request) Successful in 57s
CI (PR) / typecheck (pull_request) Successful in 33s
CI (PR) / knip (pull_request) Successful in 33s
CI (PR) / cycles (pull_request) Successful in 34s
CI (PR) / unit (pull_request) Successful in 45s
CI (PR) / build (pull_request) Has been skipped
CI (PR) / int (pull_request) Successful in 1m58s
CI (PR) / e2e (1) (pull_request) Failing after 3m8s
CI (PR) / e2e (2) (pull_request) Failing after 3m11s
CI (PR) / checks (pull_request) Failing after 1s
44 lines
1.9 KiB
TypeScript
44 lines
1.9 KiB
TypeScript
import os from 'node:os'
|
||
import path from 'node:path'
|
||
|
||
import react from '@vitejs/plugin-react'
|
||
import tsconfigPaths from 'vite-tsconfig-paths'
|
||
import { defineConfig } from 'vitest/config'
|
||
|
||
// Cap forks on high-core local machines so Payload pools stay under Docker
|
||
// Postgres max_connections (default worker count ≈ CPUs; 16× pool-max-10 ≈
|
||
// 160 clients → "too many clients already"). Do NOT set a literal
|
||
// `maxWorkers: 8` on CI: Vitest treats that as "use up to 8" even on 2–4
|
||
// vCPU runners, which starves shared advisory leases (invite/consent) and
|
||
// times out at 15s. Leave CI on Vitest's CPU-relative default — except on
|
||
// self-hosted high-core runners (Forgejo homeserver: 8 CPUs → 8 forks ×
|
||
// pool-10 already overflows the service Postgres' 100 clients), where the
|
||
// workflow pins VITEST_MAX_WORKERS=4 (the "too many clients" failure mode
|
||
// landed there in CI run 180).
|
||
const maxWorkers = process.env.VITEST_MAX_WORKERS
|
||
? Number(process.env.VITEST_MAX_WORKERS)
|
||
: process.env.CI
|
||
? undefined
|
||
: Math.min(8, os.availableParallelism())
|
||
|
||
export default defineConfig({
|
||
resolve: {
|
||
alias: {
|
||
'server-only': path.resolve(process.cwd(), 'tests/helpers/serverOnly.ts'),
|
||
},
|
||
},
|
||
plugins: [tsconfigPaths(), react()],
|
||
test: {
|
||
environment: 'jsdom',
|
||
setupFiles: ['./vitest.setup.ts'],
|
||
include: ['tests/int/**/*.int.spec.ts'],
|
||
...(maxWorkers === undefined ? {} : { maxWorkers }),
|
||
// Int specs hit a real Postgres under a parallel suite, so wall time is
|
||
// dominated by pool contention, not by the code under test. The 5s
|
||
// default made legitimately heavy RSC-composition tests flake as the
|
||
// suite grew (municipalityPageData was the first); one global budget
|
||
// beats per-test overrides. Genuinely hung tests still fail — just 10s
|
||
// later. The unit suite keeps the 5s default.
|
||
testTimeout: 15_000,
|
||
},
|
||
})
|