This repository was archived by the owner on Sep 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
52 lines (51 loc) · 2.08 KB
/
Copy pathvitest.config.ts
File metadata and controls
52 lines (51 loc) · 2.08 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
import react from '@vitejs/plugin-react';
import path from 'path';
import tsconfigPaths from 'vite-tsconfig-paths';
import { defineConfig } from 'vitest/config';
export default defineConfig({
plugins: [react(), tsconfigPaths()],
test: {
environment: 'jsdom', // Use JSDOM for browser-like environment
globals: true, // Expose Vitest APIs globally
setupFiles: './vitest.setup.ts', // Setup file for @testing-library/jest-dom
include: ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], // Test file patterns
exclude: ['node_modules', 'dist', '.idea', '.git', '.cache'], // Exclude common directories
testTimeout: 10000, // Increase timeout for API tests
coverage: {
enabled: false, // Disable coverage by default
reporter: ['text', 'json', 'html']
},
deps: {
inline: [/^(?!.*vitest).*$/]
},
// Override environment for specific test files
environmentMatchGlobs: [
['app/api/**', 'node'], // Run API tests in Node.js environment
['lib/api/**', 'node'] // Run lib API tests in Node.js environment
],
alias: {
// Configure path aliases to match your tsconfig.json
'@/components': path.resolve(__dirname, './components'),
'@/context': path.resolve(__dirname, './context'),
'@/lib': path.resolve(__dirname, './lib'),
'@/hooks': path.resolve(__dirname, './hooks'),
'@/app': path.resolve(__dirname, './app'),
'@/utils': path.resolve(__dirname, './utils'),
'@/types': path.resolve(__dirname, './types'),
'@/test-utils': path.resolve(__dirname, './test-utils')
// Add other aliases as needed
}
},
resolve: {
alias: {
'@/components': path.resolve(__dirname, './components'),
'@/context': path.resolve(__dirname, './context'),
'@/lib': path.resolve(__dirname, './lib'),
'@/hooks': path.resolve(__dirname, './hooks'),
'@/app': path.resolve(__dirname, './app'),
'@/utils': path.resolve(__dirname, './utils'),
'@/types': path.resolve(__dirname, './types'),
'@/test-utils': path.resolve(__dirname, './test-utils')
}
}
});