Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
103 lines (100 loc) · 3.82 KB
/
Copy pathvitest.config.ts
File metadata and controls
103 lines (100 loc) · 3.82 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
/**
* Vitest configuration for reborn-mark renderer tests.
*
* Strategy:
* - Inherit Vite's resolve aliases so test imports resolve identically
* to dev/build (no parallel alias map to drift). We achieve this by
* re-declaring the alias map (the same one in vite.config.js) instead
* of mergeConfig — vite.config.js has Tauri/server-port specifics we
* don't want in the test runner, and importing the config function
* would pull those in.
* - jsdom environment for DOM access (Vue + Pinia + Element Plus all
* touch document at module load time).
* - Globals enabled so test files can use describe/it/expect/vi without
* imports — keeps the Phase-4 boilerplate minimal.
* - setupFiles installs Tauri API mocks + window.* shim globals before
* each test file loads.
*/
import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import svgLoader from 'vite-svg-loader'
import { resolve, dirname } from 'path'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
export default defineConfig({
plugins: [vue(), svgLoader()],
resolve: {
alias: {
'@': resolve(__dirname, 'src/renderer/src'),
common: resolve(__dirname, 'src/common'),
muya: resolve(__dirname, 'src/muya'),
main_renderer: resolve(__dirname, 'src/_main_renderer_REMOVED_use_ipc'),
path: 'path-browserify',
fs: resolve(__dirname, 'src/renderer/src/util/fs-shim.js'),
'electron-log/renderer': resolve(__dirname, 'src/renderer/src/_shims/electron-log.js'),
'electron-log': resolve(__dirname, 'src/renderer/src/_shims/electron-log.js'),
'@hfelix/electron-localshortcut/src/atom-keymap': resolve(
__dirname,
'src/renderer/src/_shims/hfelix-localshortcut.js'
),
'@hfelix/electron-localshortcut': resolve(
__dirname,
'src/renderer/src/_shims/hfelix-localshortcut.js'
)
},
extensions: ['.mjs', '.js', '.ts', '.json', '.vue']
},
define: {
'process.platform': JSON.stringify(process.platform),
'process.env.NODE_ENV': JSON.stringify('test')
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: ['./tests/renderer/setup.ts'],
include: [
'src/renderer/**/*.{test,spec}.{js,ts}',
'tests/renderer/**/*.{test,spec}.{js,ts}'
],
// Existing M-013-A contract stubs in src/renderer/src/ipc/**/*.test.ts
// are TYPE-ONLY assertions (no describe/it blocks) consumed by
// `npm run typecheck:ipc`, not by vitest. Exclude them here so vitest
// doesn't fail on "No test suite found". Phase-4 may relocate them
// but Phase-3 must not modify production code.
exclude: [
'**/node_modules/**',
'**/dist/**',
'src/renderer/src/ipc/contract/contract.test.ts',
'src/renderer/src/ipc/runtime/runtime.test.ts'
],
pool: 'forks',
poolOptions: { forks: { maxForks: 2 } },
coverage: {
provider: 'v8',
reporter: ['text', 'html', 'lcov'],
include: ['src/renderer/src/**/*.{js,ts,vue}'],
exclude: [
'src/renderer/src/_shims/**',
'src/renderer/dist/**',
'tests/**',
'**/*.test.{js,ts}',
'**/*.spec.{js,ts}',
'src/renderer/src/codeMirror/loadmode.js',
'src/renderer/src/main.js'
],
thresholds: {
statements: 91.8,
branches: 85.0,
functions: 84.1,
lines: 92.74,
// C-2 lesson: autoUpdate rewrites these committed thresholds from
// whatever coverage a LOCAL run measured — including scoped runs
// (single test file), which once silently raised the gate to a
// scoped 100% and broke CI. The gate is now static; raise these
// values manually from a deliberate full-suite coverage run.
autoUpdate: false
}
}
}
})