-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathvitest.config.ts
More file actions
94 lines (87 loc) · 3.15 KB
/
vitest.config.ts
File metadata and controls
94 lines (87 loc) · 3.15 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
import { defineConfig } from 'vitest/config';
import path from 'path';
const aliases = {
'@/': path.resolve(__dirname, './packages/desktop/src') + '/',
'@process/': path.resolve(__dirname, './packages/desktop/src/process') + '/',
'@renderer/': path.resolve(__dirname, './packages/desktop/src/renderer') + '/',
'@worker/': path.resolve(__dirname, './packages/desktop/src/process/worker') + '/',
'@mcp/models/': path.resolve(__dirname, './packages/desktop/src/common/models') + '/',
'@mcp/types/': path.resolve(__dirname, './packages/desktop/src/common') + '/',
'@mcp/': path.resolve(__dirname, './packages/desktop/src/common') + '/',
};
export default defineConfig({
resolve: {
alias: aliases,
},
test: {
globals: true,
testTimeout: 10000,
// Use projects to run different environments (Vitest 4+)
projects: [
// Node environment tests (existing tests)
{
extends: true,
test: {
name: 'node',
environment: 'node',
include: [
'tests/unit/**/*.test.ts',
'tests/unit/**/test_*.ts',
'tests/integration/**/*.test.ts',
'tests/regression/**/*.test.ts',
],
exclude: ['tests/unit/**/*.dom.test.ts', 'tests/unit/**/*.dom.test.tsx'],
setupFiles: ['./tests/vitest.setup.ts'],
},
},
// jsdom environment tests (React component/hook tests)
{
extends: true,
test: {
name: 'dom',
environment: 'jsdom',
include: ['tests/unit/**/*.dom.test.ts', 'tests/unit/**/*.dom.test.tsx'],
setupFiles: ['./tests/vitest.dom.setup.ts'],
},
},
],
benchmark: {
include: ['tests/bench/**/*.bench.ts'],
outputFile: './bench-results.json',
},
coverage: {
provider: 'v8',
reporter: ['text', 'text-summary', 'html', 'lcov'],
reportsDirectory: './coverage',
// Cover ALL source code by default — new files are automatically included.
// Only exclude files that genuinely cannot be unit-tested (entry points,
// type-only files, static assets, etc.).
include: ['packages/desktop/src/**/*.{ts,tsx}', 'packages/**/src/**/*.{ts,tsx}'],
exclude: [
// Type declaration files (no runtime code)
'packages/**/src/**/*.d.ts',
// Electron entry points (require Electron runtime)
'packages/desktop/src/index.ts',
'packages/desktop/src/preload.ts',
// Shims / polyfills
'packages/desktop/src/common/utils/shims/**',
// Pure type / constant files
'packages/desktop/src/common/types/**',
// Static assets and i18n JSON (no logic)
'packages/desktop/src/renderer/**/*.json',
'packages/desktop/src/renderer/**/*.svg',
'packages/desktop/src/renderer/**/*.css',
// i18n config (JSON-only)
'packages/desktop/src/common/config/i18n-config.json',
],
// Thresholds apply to the included file set.
// Keeping them informational until coverage ramps up across all files.
thresholds: {
statements: 0,
branches: 0,
functions: 0,
lines: 0,
},
},
},
});