-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvitest.config.ts
More file actions
75 lines (65 loc) · 2.24 KB
/
Copy pathvitest.config.ts
File metadata and controls
75 lines (65 loc) · 2.24 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 path from 'node:path'
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
// Serve Vitest UI at root so Codespaces port forwarding works (default is /__vitest__/)
uiBase: '/',
// Use jsdom environment for testing React components
environment: 'jsdom',
// Setup file (equivalent to Jest's setupFilesAfterEnv)
setupFiles: ['./vitest.setup.ts'],
// Test file patterns (equivalent to Jest's testMatch)
include: ['**/*.{spec,test}.{ts,tsx,js,jsx,mjs}'],
// Exclude Playwright integration tests and .git directory
exclude: ['**/tests/integration/**', '**/node_modules/**', '.git/**'],
reporters: [
'verbose', // Use default reporter for console output
[
'junit',
{
outputFile: './test-results/test-results-junit.xml', // Output file for JUnit report
suiteName: 'Vitest Tests', // Name of the test suites
classNameTemplate: '{filename}', // Template for class names in the report
},
],
],
// Coverage configuration
coverage: {
provider: 'v8',
reportsDirectory: './coverage', // Output coverage reports to ./coverage folder
reporter: ['text', 'json', 'html', 'clover', 'lcov'], // Multiple formats including Codecov-compatible ones
include: [
'app/**/*.{ts,tsx}',
'components/**/*.{ts,tsx}',
'lib/**/*.{ts,tsx}',
// Include deterministic script logic in coverage.
'scripts/**/*.{js,mjs}',
],
exclude: [
'**/*.d.ts',
'**/__tests__/**',
'**/*.{test,spec}.{ts,tsx,js,jsx,mjs}',
'test-utils/**',
'vitest.setup.ts',
// Exclude orchestration-only scripts that mainly shell out / wire env.
'scripts/prebuild.js',
'scripts/security-audit.js',
],
thresholds: {
branches: 85,
functions: 85,
lines: 85,
statements: 85,
},
},
// Globals (makes test functions available without imports)
globals: true,
},
resolve: {
alias: {
// Module path mapping (equivalent to Jest's moduleNameMapper)
'@': path.resolve(__dirname, '.'),
},
},
// Handle CSS and asset imports (CSS modules will be handled automatically)
})