-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvitest.config.ts
More file actions
111 lines (104 loc) · 3.05 KB
/
vitest.config.ts
File metadata and controls
111 lines (104 loc) · 3.05 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
import { defineConfig } from 'vitest/config';
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';
import { playwright } from '@vitest/browser-playwright';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Dedicated Vitest config file for VSCode plugin compatibility
// The VSCode Vitest plugin specifically looks for vitest.config.* files
// This ensures the setup file with SQLite initialization is properly loaded
export default defineConfig({
resolve: {
dedupe: ['react', 'react-dom'],
alias: {
'@massalabs/gossip-sdk': resolve(__dirname, 'gossip-sdk/src'),
react: resolve(__dirname, 'node_modules/react'),
'react-dom': resolve(__dirname, 'node_modules/react-dom'),
},
},
test: {
globals: true,
// Use "projects" for multiple test environments
projects: [
// Project 1: Browser mode for component tests
{
extends: true,
optimizeDeps: {
include: [
'react',
'react/jsx-dev-runtime',
'react-dom',
'react-dom/client',
'vitest-browser-react',
],
},
test: {
name: 'browser',
browser: {
enabled: true,
provider: playwright(),
headless: true,
instances: [{ browser: 'chromium' }],
},
setupFiles: [resolve(__dirname, 'test/setup.browser.ts')],
include: [
'test/**/*.browser.{test,spec}.{ts,tsx}',
'test/**/browser/**/*.{test,spec}.{ts,tsx}',
],
},
},
// Project 2: jsdom for unit tests (DOM simulation - faster)
{
test: {
name: 'jsdom',
environment: 'jsdom',
setupFiles: [resolve(__dirname, 'test/setup.ts')],
include: [
'test/**/*.jsdom.{test,spec}.{ts,tsx}',
'test/**/jsdom/**/*.{test,spec}.{ts,tsx}',
],
},
},
// Project 3: Node environment for pure logic tests (no DOM)
{
test: {
name: 'node',
environment: 'node',
include: [
'test/**/*.node.{test,spec}.{ts,tsx}',
'test/**/node/**/*.{test,spec}.{ts,tsx}',
],
},
},
// Project 4: Default jsdom for tests without suffix (catch-all)
{
test: {
name: 'unit',
environment: 'jsdom',
setupFiles: [resolve(__dirname, 'test/setup.ts')],
include: ['test/**/*.{test,spec}.{ts,tsx}'],
exclude: [
'test/**/*.browser.*',
'test/**/*.jsdom.*',
'test/**/*.node.*',
'test/**/browser/**',
'test/**/jsdom/**',
'test/**/node/**',
],
},
},
],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: [
'node_modules/',
'src/test/',
'**/*.d.ts',
'**/*.config.*',
'**/mockData',
'gossip-sdk/src/assets/generated/wasm/**',
],
},
},
});