-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
143 lines (140 loc) · 5.83 KB
/
vitest.config.ts
File metadata and controls
143 lines (140 loc) · 5.83 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import { defineConfig } from 'vitest/config'
// Disable coverage thresholds in CI when running sharded tests
// (each shard only sees partial coverage, so thresholds will always fail)
const skipThresholds = process.env.CI === 'true'
const workspaceAliases = {
'@xnetjs/canvas': new URL('./packages/canvas/src/index.ts', import.meta.url).pathname,
'@xnetjs/cli': new URL('./packages/cli/src/index.ts', import.meta.url).pathname,
'@xnetjs/core': new URL('./packages/core/src/index.ts', import.meta.url).pathname,
'@xnetjs/crypto': new URL('./packages/crypto/src/index.ts', import.meta.url).pathname,
'@xnetjs/data': new URL('./packages/data/src/index.ts', import.meta.url).pathname,
'@xnetjs/data-bridge': new URL('./packages/data-bridge/src/index.ts', import.meta.url).pathname,
'@xnetjs/devtools': new URL('./packages/devtools/src/index.ts', import.meta.url).pathname,
'@xnetjs/editor': new URL('./packages/editor/src/index.ts', import.meta.url).pathname,
'@xnetjs/formula': new URL('./packages/formula/src/index.ts', import.meta.url).pathname,
'@xnetjs/history': new URL('./packages/history/src/index.ts', import.meta.url).pathname,
'@xnetjs/hub': new URL('./packages/hub/src/index.ts', import.meta.url).pathname,
'@xnetjs/identity': new URL('./packages/identity/src/index.ts', import.meta.url).pathname,
'@xnetjs/network': new URL('./packages/network/src/index.ts', import.meta.url).pathname,
'@xnetjs/plugins': new URL('./packages/plugins/src/index.ts', import.meta.url).pathname,
'@xnetjs/query': new URL('./packages/query/src/index.ts', import.meta.url).pathname,
'@xnetjs/react/internal': new URL('./packages/react/src/internal.ts', import.meta.url).pathname,
'@xnetjs/react': new URL('./packages/react/src/index.ts', import.meta.url).pathname,
'@xnetjs/sdk': new URL('./packages/sdk/src/index.ts', import.meta.url).pathname,
'@xnetjs/sqlite/memory': new URL('./packages/sqlite/src/adapters/memory.ts', import.meta.url)
.pathname,
'@xnetjs/sqlite': new URL('./packages/sqlite/src/index.ts', import.meta.url).pathname,
'@xnetjs/storage': new URL('./packages/storage/src/index.ts', import.meta.url).pathname,
'@xnetjs/sync': new URL('./packages/sync/src/index.ts', import.meta.url).pathname,
'@xnetjs/telemetry': new URL('./packages/telemetry/src/index.ts', import.meta.url).pathname,
'@xnetjs/ui': new URL('./packages/ui/src/index.ts', import.meta.url).pathname,
'@xnetjs/vectors': new URL('./packages/vectors/src/index.ts', import.meta.url).pathname,
'@xnetjs/views': new URL('./packages/views/src/index.ts', import.meta.url).pathname
}
export default defineConfig({
resolve: {
alias: workspaceAliases
},
test: {
globals: true,
testTimeout: 10000,
hookTimeout: 10000,
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
exclude: ['**/node_modules/**', '**/dist/**', '**/*.test.ts', '**/index.ts'],
thresholds: skipThresholds
? undefined
: {
statements: 80,
branches: 75,
functions: 80,
lines: 80
}
},
projects: [
{
// Pure TS packages — no DOM, no native modules, no real I/O
// Safe to share state between test files for maximum speed
extends: true,
test: {
name: 'unit',
environment: 'node',
pool: 'threads',
isolate: false,
include: [
'packages/{cli,crypto,core,data,formula,history,identity,network,query,sqlite,storage,sync,telemetry,vectors}/src/**/*.test.ts',
'packages/{cli,crypto,core,data,formula,history,identity,network,query,sqlite,storage,sync,telemetry,vectors}/test/**/*.test.ts'
],
// data-bridge tests run separately - they have Yjs module import order issues
// when combined with other tests in the same worker thread
exclude: ['packages/data-bridge/**']
}
},
{
// DOM packages — need jsdom environment, keep isolation for clean DOM state
extends: true,
test: {
name: 'dom',
environment: 'jsdom',
pool: 'threads',
isolate: true,
include: [
'packages/{canvas,react,views,devtools,ui}/src/**/*.test.{ts,tsx}',
'packages/{canvas,react,views,devtools,ui}/test/**/*.test.{ts,tsx}'
]
},
resolve: {
alias: {
// Mock mermaid for canvas tests (optional peer dependency)
mermaid: new URL('./packages/canvas/src/__mocks__/mermaid.ts', import.meta.url).pathname
}
}
},
{
// Integration packages — real WebSocket servers, real I/O
// Must keep isolation to prevent port conflicts and shared state
extends: true,
test: {
name: 'integration',
environment: 'node',
pool: 'forks',
isolate: true,
testTimeout: 15000,
include: [
'packages/{hub,plugins,sdk}/src/**/*.test.ts',
'packages/{hub,plugins,sdk}/test/**/*.test.ts'
],
server: {
deps: {
external: ['better-sqlite3', 'ws', '@hono/node-server']
}
}
}
},
{
// Editor package — jsdom + custom setup file
extends: true,
test: {
name: 'editor',
environment: 'jsdom',
pool: 'threads',
isolate: true,
setupFiles: ['./packages/editor/src/test/setup.ts'],
include: ['packages/editor/src/**/*.test.{ts,tsx}']
}
},
{
// Data-bridge package — isolate to avoid Yjs module import conflicts
extends: true,
test: {
name: 'data-bridge',
environment: 'node',
pool: 'forks',
isolate: true,
include: ['packages/data-bridge/src/**/*.test.ts']
}
}
]
}
})