teqo-backup/vitest.config.mts
Francisco Solla f87e382836
fix(campanha): unblock dobradinhas list SSR for Assessores (#386)
* fix(campanha): unblock dobradinhas list SSR for Assessores column

Drop CampaignTableHead description on Assessores — its hover tooltip plus
StateDeputyAdvisorRelationCell breaks production SSR with an undefined element.

* fix(test): keep int gate under Postgres connection ceiling

Cap vitest workers and raise Docker max_connections so high-core laptops
stop failing the suite with cascading "too many clients" / QueryError noise.

* fix(test): do not force eight int workers on CI

An explicit maxWorkers: 8 raised parallelism on 2–4 vCPU runners and
starved shared invite/consent advisory leases (15s timeouts). Cap only
on local high-core hosts; leave CI on Vitest's CPU-relative default.

* style(test): format vitest.config.mts
2026-08-06 00:19:01 +00:00

36 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.
const maxWorkers = 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,
},
})