-
Notifications
You must be signed in to change notification settings - Fork 747
Expand file tree
/
Copy pathvitest.config.ts
More file actions
120 lines (116 loc) 路 3.74 KB
/
Copy pathvitest.config.ts
File metadata and controls
120 lines (116 loc) 路 3.74 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import { defineConfig } from 'vitest/config'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
const isCustomElement = (tag: string) =>
tag === 'voice-agent-widget' || tag.startsWith('ui-resource-renderer')
const vuePlugin = () =>
vue({
template: {
compilerOptions: {
isCustomElement
}
}
})
const TEST_TIMEOUT_MS = 10000
const TEST_MAX_WORKERS = 2
export default defineConfig({
test: {
globals: true,
// electron-store 11 is ESM-only and gets externalized; inline it so its
// `electron` import resolves to the test mock instead of the real package.
server: {
deps: {
inline: ['electron-store']
}
},
// Use projects to define different configurations for main and renderer tests
// This allows each test suite to use the correct alias resolution
projects: [
{
plugins: [vuePlugin()],
test: {
name: 'renderer',
environment: 'jsdom',
include: ['test/renderer/**/*.{test,spec}.{js,ts}'],
setupFiles: ['./test/setup.renderer.ts'],
globals: true,
testTimeout: TEST_TIMEOUT_MS,
hookTimeout: TEST_TIMEOUT_MS,
maxWorkers: TEST_MAX_WORKERS
},
resolve: {
alias: [
// Renderer process aliases (match electron.vite.config.ts renderer config)
{ find: '@/', replacement: resolve('src/renderer/src/') + '/' },
{ find: '@api', replacement: resolve('src/renderer/api') },
{
find: '@renderer-notifications',
replacement: resolve('src/renderer/services/notifications')
},
{ find: '@shared', replacement: resolve('src/shared') },
{ find: '@shadcn', replacement: resolve('src/shadcn') },
{ find: '@dc-ui', replacement: resolve('src/dc-ui') },
{ find: 'electron', replacement: resolve('test/mocks/electron.ts') },
{ find: '@electron-toolkit/utils', replacement: resolve('test/mocks/electron-toolkit-utils.ts') }
]
}
},
{
plugins: [vuePlugin()],
test: {
name: 'main',
environment: 'node',
include: ['test/main/**/*.{test,spec}.{js,ts}'],
setupFiles: ['./test/setup.ts'],
globals: true,
testTimeout: TEST_TIMEOUT_MS,
hookTimeout: TEST_TIMEOUT_MS,
maxWorkers: TEST_MAX_WORKERS,
// electron-store 11 is ESM-only and would be externalized; inline it so
// its `electron` import resolves to the test mock, not the real package.
server: {
deps: {
inline: ['electron-store']
}
}
},
resolve: {
alias: [
// Main process aliases (match electron.vite.config.ts main config)
{ find: '@/', replacement: resolve('src/main/') + '/' },
{ find: '@shared', replacement: resolve('src/shared') },
{ find: 'electron', replacement: resolve('test/mocks/electron.ts') },
{ find: '@electron-toolkit/utils', replacement: resolve('test/mocks/electron-toolkit-utils.ts') }
]
}
}
],
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
reportsDirectory: './coverage',
exclude: [
'node_modules/**',
'dist/**',
'out/**',
'test/**',
'**/*.d.ts',
'scripts/**',
'build/**',
'.vscode/**',
'.git/**'
],
thresholds: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
}
},
testTimeout: TEST_TIMEOUT_MS,
hookTimeout: TEST_TIMEOUT_MS,
maxWorkers: TEST_MAX_WORKERS
}
})