-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathvitest.config.ts
More file actions
95 lines (91 loc) · 3.55 KB
/
Copy pathvitest.config.ts
File metadata and controls
95 lines (91 loc) · 3.55 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
import { defineConfig } from 'vitest/config';
import { resolve } from 'path';
import react from '@vitejs/plugin-react';
const sharedExclude = [
'node_modules',
'dist',
'tests/e2e/**/*.spec.ts',
'tests/e2e/**/*.spec.tsx',
'tests/manual/**/*.manual.test.ts',
'tests/manual/**/*.manual.test.tsx',
];
const sharedResolve = {
alias: [
{
find: '@tanstack/react-query',
replacement: resolve(__dirname, './src/presentation/web/node_modules/@tanstack/react-query'),
},
{ find: '@shepai/core', replacement: resolve(__dirname, './packages/core/src') },
{ find: '@/application', replacement: resolve(__dirname, './packages/core/src/application') },
{
find: '@/infrastructure',
replacement: resolve(__dirname, './packages/core/src/infrastructure'),
},
{ find: '@/domain', replacement: resolve(__dirname, './packages/core/src/domain') },
{ find: '@/components', replacement: resolve(__dirname, './src/presentation/web/components') },
{ find: '@/lib', replacement: resolve(__dirname, './src/presentation/web/lib') },
{ find: '@/hooks', replacement: resolve(__dirname, './src/presentation/web/hooks') },
{ find: '@/app', replacement: resolve(__dirname, './src/presentation/web/app') },
{ find: '@/types', replacement: resolve(__dirname, './src/presentation/web/types') },
{ find: '@cli', replacement: resolve(__dirname, './src') },
{ find: '@', replacement: resolve(__dirname, './src') },
{ find: '@tests', replacement: resolve(__dirname, './tests') },
],
};
// Ensure React loads its development bundle (which exports `act`) even when
// the shell environment has NODE_ENV=production (e.g. after a build step).
(process.env as Record<string, string>).NODE_ENV = 'test';
export default defineConfig({
plugins: [react()],
test: {
globals: false,
testTimeout: 10000,
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: ['node_modules', 'dist', 'tests', '**/*.d.ts', '**/*.config.*'],
},
// Two projects: web tests get jsdom + setup, everything else runs in fast node env
projects: [
{
test: {
name: 'web',
include: [
'tests/unit/presentation/web/**/*.test.ts',
'tests/unit/presentation/web/**/*.test.tsx',
],
exclude: sharedExclude,
environment: 'jsdom',
setupFiles: ['tests/unit/presentation/web/setup.ts'],
testTimeout: 10000,
},
resolve: sharedResolve,
},
{
test: {
name: 'node',
include: ['tests/**/*.test.ts', 'tests/**/*.test.tsx'],
exclude: [
...sharedExclude,
'tests/unit/presentation/web/**/*.test.ts',
'tests/unit/presentation/web/**/*.test.tsx',
],
environment: 'node',
setupFiles: ['tests/unit/setup.ts'],
// testTimeout / hookTimeout are sized for the heaviest integration
// tests, which spawn real git harnesses. On the Windows CI runner
// git's process startup + filesystem latency can push a single
// setup or test past vitest's defaults (10s hook / 30s test) even
// when the test itself is healthy. Bumping the project ceilings
// turns Windows-only flakes into either a clean pass or a real
// signal we have to investigate, never a false positive at the
// arbitrary default boundary.
testTimeout: 60000,
hookTimeout: 20000,
},
resolve: sharedResolve,
},
],
},
resolve: sharedResolve,
});