-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvitest.config.unit.ts
More file actions
40 lines (39 loc) · 1.29 KB
/
vitest.config.unit.ts
File metadata and controls
40 lines (39 loc) · 1.29 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
import { defineConfig } from 'vitest/config';
import react from '@vitejs/plugin-react';
import path from 'path';
/**
* Vitest v4 config for unit tests only
*
* Runs in jsdom (fast, lightweight) and excludes Storybook stories.
* Run via: pnpm test:unit
*/
export default defineConfig({
plugins: [react()],
test: {
name: 'unit',
globals: true,
environment: 'jsdom',
include: ['src/**/*.test.{ts,tsx}'],
exclude: ['src/**/*.stories.{ts,tsx}', 'node_modules'],
setupFiles: ['./vitest.setup.ts'],
// Vitest 4: Explicitly configure fake timers to avoid queueMicrotask OOM issues
// See: https://github.com/vitest-dev/vitest/issues/7288
fakeTimers: {
toFake: ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'setImmediate', 'clearImmediate', 'Date'],
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
'@components': path.resolve(__dirname, './src/components'),
'@pages': path.resolve(__dirname, './src/pages'),
'@hooks': path.resolve(__dirname, './src/hooks'),
'@utils': path.resolve(__dirname, './src/utils'),
'@api': path.resolve(__dirname, './src/api'),
'@assets': path.resolve(__dirname, './src/assets'),
},
},
optimizeDeps: {
include: ['react-dom/client', 'zod/mini'],
},
});