-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvitest.config.ts
More file actions
55 lines (53 loc) · 1.69 KB
/
Copy pathvitest.config.ts
File metadata and controls
55 lines (53 loc) · 1.69 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
import { defineConfig } from 'vitest/config';
// Check Node.js version to determine configuration
const nodeVersion = process.version;
const nodeMajorVersion = parseInt(nodeVersion.split('.')[0].replace('v', ''));
export default defineConfig({
test: {
// Enable TypeScript support in test files
typecheck: {
enabled: false, // Disable type checking to avoid issues with .ts imports
include: ['**/*.test.ts'],
},
// Configure test environment
environment: 'node',
// Set up file extensions that should be treated as modules
extensions: ['ts', 'tsx', 'js', 'jsx'],
// Exclude development files from testing
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/src/bin/commit-msg.dev.ts',
// Conditionally exclude hook tests if environment variable is set
...(process.env.SKIP_HOOK_TESTS === 'true' ? ['**/hook.test.ts'] : []),
],
// Add test timeout for slower environments
testTimeout: 60000, // 60 seconds
hookTimeout: 30000, // 30 seconds
// Configure coverage
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
include: ['src/**'],
exclude: [
'src/bin/**',
'src/templates/**',
'**/*.d.ts',
'**/node_modules/**',
'**/dist/**',
],
},
},
// Configure how to resolve imports in the project
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
},
// Configure esbuild to handle TypeScript files correctly
esbuild: {
target: nodeMajorVersion >= 18 ? `node${nodeMajorVersion}` : 'node18',
loader: 'ts',
// Add platform-specific options for better compatibility
platform: 'node',
format: 'esm',
},
});