-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
57 lines (53 loc) · 2.03 KB
/
Copy pathvitest.config.ts
File metadata and controls
57 lines (53 loc) · 2.03 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
import { defineConfig } from 'vitest/config';
import tsconfigPaths from 'vite-tsconfig-paths';
import path from 'path';
/**
* Vitest Configuration for Electron Main Process Testing
*
* Architecture: Separates E2E (Playwright) from Unit/Integration (Vitest)
*
* CRITICAL: Tests run in Node.js environment, but better-sqlite3 must be
* rebuilt for Electron ABI. Use `npm run db:rebuild` after installing dependencies.
*
* For native modules to work correctly:
* 1. Ensure better-sqlite3 is in dependencies (not devDependencies)
* 2. Run `npm run db:rebuild` to rebuild for Electron ABI
* 3. Tests use Node.js environment but native modules are Electron-compatible
*/
export default defineConfig({
plugins: [tsconfigPaths()],
test: {
// Architecture strictness: separate E2E (Playwright) from Unit/Integration (Vitest)
include: [
'tests/unit/**/*.{test,spec}.{ts,tsx}',
'tests/integration/**/*.{test,spec}.ts',
'tests/property/**/*.{test,spec}.ts',
],
exclude: ['**/node_modules/**', '**/dist/**', '**/out/**', 'tests/e2e/**'],
// Node environment for Main Process testing (native modules work here)
globals: true,
environment: 'node',
// Timeout adjustment for Electron startup overhead and native module loading
testTimeout: 15000,
hookTimeout: 15000,
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: ['node_modules/', 'tests/', '**/*.d.ts', '**/out/**', '**/dist/**'],
},
alias: {
// Renderer sources use tsconfig `@/*` → `src/renderer/*` (`@/lib/utils`).
// Test files use `@/main` and `@/renderer`, so `@` stays `src/`.
'@/lib': path.resolve(__dirname, './src/renderer/lib'),
'@': path.resolve(__dirname, './src'),
'@shared': path.resolve(__dirname, './src/shared'),
},
},
// Externalize native modules to prevent Vite from bundling them
// This ensures better-sqlite3 .node files are loaded correctly
build: {
rollupOptions: {
external: ['better-sqlite3'],
},
},
});