-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvitest.config.ts
More file actions
96 lines (86 loc) · 2.5 KB
/
vitest.config.ts
File metadata and controls
96 lines (86 loc) · 2.5 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
import { defineConfig } from 'vitest/config';
import { resolve } from 'path';
import { readFileSync } from 'fs';
// Read package.json to get version information
const pkg = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf-8'));
export default defineConfig({
test: {
// Test environment configuration
globals: true,
environment: 'node',
// File matching patterns
include: ['tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts}'],
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/.{idea,git,cache,output,temp}/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
],
// Coverage configuration
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html', 'lcov', 'clover'],
reportsDirectory: './coverage',
include: ['src/**/*.{js,ts}'],
exclude: [
'src/**/*.d.ts',
'src/**/*.test.{js,ts}',
'src/**/*.spec.{js,ts}',
'src/**/index.ts', // Entry files usually just re-export
'src/**/*.config.{js,ts}',
],
thresholds: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
},
// Enable all coverage features
all: true,
skipFull: false,
},
// Timeout configuration
testTimeout: 10000,
hookTimeout: 10000,
teardownTimeout: 5000,
// Performance configuration
isolate: true,
pool: 'threads',
poolOptions: {
threads: {
singleThread: false,
minThreads: 1,
maxThreads: 4,
},
},
// Output configuration
reporters: ['verbose', 'html'],
outputFile: {
html: './coverage/test-results.html',
},
// Mock configuration
mockReset: true,
clearMocks: true,
restoreMocks: true,
},
// Resolve configuration (consistent with vite.config.ts)
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'@/types': resolve(__dirname, 'src/types'),
'@/config': resolve(__dirname, 'src/config'),
'@/utils': resolve(__dirname, 'src/utils'),
'@/cli': resolve(__dirname, 'src/cli'),
},
},
// Environment variables
define: {
'process.env.NODE_ENV': JSON.stringify('test'),
// Inject version information (consistent with vite.config.ts)
'__PKG_NAME__': JSON.stringify(pkg.name),
'__PKG_VERSION__': JSON.stringify(pkg.version),
'__PKG_DESCRIPTION__': JSON.stringify(pkg.description),
},
});