-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvitest.config.ts
More file actions
99 lines (97 loc) Β· 5.03 KB
/
Copy pathvitest.config.ts
File metadata and controls
99 lines (97 loc) Β· 5.03 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/// <reference types="vitest" />
import path from 'node:path';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vitest/config';
import coverageThresholds from './scripts/coverage-thresholds.json' with { type: 'json' };
export default defineConfig({
plugins: [react()],
// QNBS-v3: Map optional ai-core peer deps so workers/ and services/ can import them in tests.
resolve: {
alias: {
'@huggingface/transformers': path.resolve(
'./packages/ai-core/node_modules/@huggingface/transformers/dist/transformers.web.js',
),
// QNBS-v3: B-3 vendor fork β resolve workspace package in tests
'@domain/collab-transport': path.resolve('./packages/collab-transport/src/index.ts'),
'@domain/worker-bus': path.resolve('./packages/worker-bus/src/index.ts'),
// QNBS-v3: Wave 1 DesktopPlatform contract β resolve workspace package in tests (mirrors the worker-bus/collab-transport aliases above)
'@domain/desktop-contracts': path.resolve('./packages/desktop-contracts/src/index.ts'),
},
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./tests/setup.ts'],
testTimeout: 30000,
// QNBS-v3: maxWorkers:1 + single test-run avoids RAM exhaustion on the low-end dev machine.
// Run pnpm exec vitest run as ONE sequential process β never concurrently with other
// heavy commands. isolate:true (default) keeps module state clean between files.
// Best Practice 2026: pool: 'threads' is stable for Vitest 4.x; 'vmThreads' is experimental.
pool: 'threads',
maxWorkers: 1,
include: [
'tests/**/*.{test,spec}.{ts,tsx}',
'components/**/*.{test,spec}.{ts,tsx}',
'packages/*/tests/**/*.{test,spec}.{ts,tsx}',
],
exclude: ['tests/e2e/**'],
// QNBS-v3: GitHub Actions annotations reporter provides inline error reporting in PR checks.
// Best Practice 2026: junit for CI artifact, github-annotations for PR inline feedback.
reporters: ['default', ['junit', { outputFile: 'reports/junit.xml' }]],
coverage: {
provider: 'v8',
// QNBS-v3: json-summary produces coverage/coverage-summary.json, consumed by
// scripts/check-coverage-ratchet.mjs (non-blocking CI step suggesting when to ratchet up).
reporter: ['text', 'lcov', 'html', 'json-summary'],
include: [
// QNBS-v3: Measure the application shell so root composition and PWA lifecycle code cannot evade coverage.
'App.tsx',
'index.tsx',
'register-sw.ts',
'app/**/*.{ts,tsx}',
'components/**/*.{ts,tsx}',
'features/**/*.{ts,tsx}',
'hooks/**/*.{ts,tsx}',
'services/**/*.{ts,tsx}',
'packages/*/src/**/*.{ts,tsx}',
],
exclude: [
'node_modules/',
'dist/',
'tests/',
'**/mocks/**',
'.storybook/',
'src-tauri/',
'**/*.stories.{ts,tsx}',
'**/*.d.ts',
// QNBS-v3: B-3 vendored JS source β excluded from coverage (upstream code, not ours)
'packages/collab-transport/src/y-webrtc.js',
'packages/collab-transport/src/crypto.js',
],
// QNBS-v3: Coverage Threshold History β Ratchet Mechanism for Node 22/24 Stability.
// WHY: Thresholds are set ~1pt below CI-measured values to absorb Node version variance.
// Node 22/24 differ in ICU data, V8 optimizations, and Web Storage API behavior.
// Best Practice 2026: Never set thresholds at exact CI values; always leave a safety margin.
// History: L71/F63/B57/S69 β L73/F65/B58/S71 (C-7) β L76/F68/B61/S74 (C-7 target,
// never actually met on CI) β L72/F64/B58/S70 (corrected, 2026-05-31)
// β L74/F66/B60/S72 (2026-06-03: ratchet to ~1pt below CI-measured 75.15/67.84/61.23/73.14
// after Phase 2.3/2.4 tests; margin absorbs Node 22/24 variance).
// β L74/F67/B60/S72 (2026-06-06: incremental ratchet to ~1pt below CI-measured values).
// β L79/F72/B65/S77 (2026-07-29, F-13: WS-9 of the CSP/crypto/doc-truth sprint β
// CI-measured L80.86/F73.78/B66.74/S79.02, identical on Node 22 and 24; capped at +5 pts
// per metric per the quarterly cap below rather than the full ~1pt-below-measured jump,
// since the straight ~1pt margin would have exceeded +5 on statements. First ratchet of
// Q3 2026 β the prior entries above are all Q2, so this is not a same-quarter stack-up).
// β L80/F72/B66/S78 (2026-08-20: expanded scope CI measured L81.63/F74.26/B67.75/S79.55;
// floor(measured β 1.5) per docs/COVERAGE-POLICY.md; Node 24 also passed).
// P1 target: L85/B75/F80 β next ratchet after verification.
// RATCHET RULE: After 3 consecutive green CI runs on both Node versions, increase each threshold
// by 1 point (max 5 points per quarter). Document the new baseline in this comment.
// QNBS-v3 (CodeRabbit): this floor includes the root application/PWA shell and blocks regressions below L80/F72/B66/S78.
thresholds: {
...coverageThresholds,
perFile: false,
},
},
},
});