-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathvitest.config.ts
More file actions
75 lines (74 loc) · 2.87 KB
/
Copy pathvitest.config.ts
File metadata and controls
75 lines (74 loc) · 2.87 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
66
67
68
69
70
71
72
73
74
75
import { defineConfig } from 'vitest/config'
import path from 'path'
export default defineConfig({
test: {
globals: true,
environment: 'node',
// GitHub-hosted ubuntu-latest is 4 vCPU. Default maxWorkers is ~50% of
// cores, which leaves half the runner idle. Pin to 4 in CI; locally leave
// headroom for the rest of the machine. Isolation stays on: turning it
// off leaked vi.mock state across files (~200 failures on a shard).
maxWorkers: process.env.CI ? 4 : undefined,
fileParallelism: true,
pool: 'forks',
// Many server tests do a first-time dynamic import() inside the test body
// (the vi.mock factory pattern). Under parallel CPU contention that load
// can exceed the 5s default — and a timeout firing mid-import() corrupts
// the module graph for later tests. 20s gives headroom; genuine hangs
// still fail well before the suite stalls.
testTimeout: 20000,
include: ['**/*.test.ts', '**/*.test.tsx'],
setupFiles: [path.resolve(__dirname, './vitest.setup.ts')],
exclude: [
'**/node_modules/**',
'**/.next/**',
'**/e2e/**',
'**/.output/**',
// Isolated git worktrees live here; they are separate checkouts with
// their own deps and must not be run by the parent repo's suite.
'**/.claude/**',
'**/*-integration.test.ts',
// Widget package has its own vitest.config.ts with happy-dom — run via
// `bun run --cwd packages/widget test`. Don't double-run from the root.
'packages/widget/**',
],
// Use ts-node or vite's transformation instead of stripping
typecheck: {
enabled: false,
},
env: {
DATABASE_URL:
process.env.TEST_DATABASE_URL ??
'postgresql://postgres:password@localhost:5432/quackback_test',
},
deps: {
optimizer: {
ssr: { enabled: true },
},
},
},
esbuild: {
// Disable esbuild's strip-only mode to properly handle TypeScript features
tsconfigRaw: {
compilerOptions: {
useDefineForClassFields: false,
},
},
},
resolve: {
alias: {
'@quackback/db/client': path.resolve(__dirname, './packages/db/src/client.ts'),
'@quackback/db/schema-version': path.resolve(
__dirname,
'./packages/db/src/schema-version.ts'
),
'@quackback/db/schema-ops': path.resolve(__dirname, './packages/db/src/schema-ops.ts'),
'@quackback/db/migrate': path.resolve(__dirname, './packages/db/src/migrate-runtime.ts'),
'@quackback/db/schema': path.resolve(__dirname, './packages/db/src/schema/index.ts'),
'@quackback/db/types': path.resolve(__dirname, './packages/db/src/types.ts'),
'@quackback/db': path.resolve(__dirname, './packages/db/index.ts'),
// Path alias for apps/web (matches tsconfig.json baseUrl: "./src" + "@/*": ["./*"])
'@': path.resolve(__dirname, './apps/web/src'),
},
},
})