-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathvitest.config.ts
More file actions
65 lines (64 loc) · 3.78 KB
/
Copy pathvitest.config.ts
File metadata and controls
65 lines (64 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
include: ['test/**/*.test.ts'],
// Force UTC before any test module loads (see
// test/lib/setupTimezone.ts). Mirrored as a bun `preload` in
// bunfig.toml so both runners marshal localDateTime identically.
setupFiles: ['./test/lib/setupTimezone.ts'],
// Per-test timeout. The default 5s is too tight for the
// docker-backed cells under heavy parallel load (an Oracle
// `withReseed` drops + recreates the schema and can spike
// past 5s during contention). 60s covers the worst legitimate
// cases without masking hangs for long. Mirrored in the bun
// branch of `scripts/_test-common.sh` (`bun test --timeout 60000`).
// No explicit `hookTimeout` — vitest inherits `testTimeout`
// for hooks, matching bun's single-knob behaviour. The slow
// hooks (`beforeAll`/`afterAll` doing container start/stop)
// already override per-call with `ctx.timeoutMs` (180_000),
// so the inherited default never bites them.
testTimeout: 60_000,
// Reuse each worker's module graph across the test files it runs
// instead of tearing the environment down and re-importing every
// module per file. With ~3k+ files the per-file re-import is the
// dominant cost: on the full `newest` matrix it took the cumulative
// `import` phase from ~493s to ~64s and cut wall time ~8x
// (79s -> 9.5s), bringing vitest into bun's ballpark — bun is fast
// for exactly this reason (it never re-isolates per file). This is
// the vitest equivalent of that model. Trade-off: module-level state
// now persists across files within a worker, so a test that mutates a
// shared singleton could leak into the next file; the suite's cells
// are self-contained (a fresh connection + mock/real runner per test),
// so this stays green across mock + native-real. Kept on the default
// `forks` pool on purpose — `threads` would additionally need
// `TZ=UTC` in the ENVIRONMENT (the late `process.env.TZ` mutation in
// test/lib/setupTimezone.ts is ignored once a worker isolate has
// touched Date) and has shown an intermittent native-addon segfault.
isolate: false,
// Tolerate files that declare a `describe` with every `test(...)`
// commented out per the symmetry rule (DESIGN.md §4). Without
// this, vitest treats those as failed suites — a soft failure
// with exit 0 normally, but a hard failure under --coverage
// that also suppresses the coverage report. The flag only
// relaxes the "no tests found" case; real assertion failures
// still fail.
passWithNoTests: true,
// All HTML output (test execution + coverage) lands under
// `.test-report/`. The test-exec report (`--reporter=html`,
// requires @vitest/ui) writes here; the coverage report
// lives in a subdirectory so the two share one wipe-and-go
// root (see `clean_coverage_dir` in scripts/_test-common.sh).
outputFile: {
html: '.test-report/index.html',
},
coverage: {
// Coverage scope. Mirrored in bunfig.toml's
// `coveragePathIgnorePatterns` so both runners report on
// the same set of files. Drops the legacy examples and
// the test infrastructure itself, keeping the report
// focused on the library's public surface.
exclude: ['src/examples/**', 'test/**', 'src/queryRunners/*', 'src/queryRunners/connectorErrorMappers/*', 'src/queryRunners/databaseErrorMappers/*'],
reportsDirectory: '.test-report/coverage',
},
},
})