-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvitest.config.ts
More file actions
120 lines (117 loc) · 4.11 KB
/
Copy pathvitest.config.ts
File metadata and controls
120 lines (117 loc) · 4.11 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 { fileURLToPath } from 'node:url'
const pkg = (name: string) =>
fileURLToPath(new URL(`./packages/${name}/src/index.ts`, import.meta.url))
const alias = {
'@ecsia/scheduler/workers': fileURLToPath(
new URL('./packages/scheduler/src/workers/index.ts', import.meta.url),
),
'@ecsia/schema': pkg('schema'),
'@ecsia/core': pkg('core'),
'@ecsia/relations': pkg('relations'),
'@ecsia/scheduler': pkg('scheduler'),
'@ecsia/serialization': pkg('serialization'),
'@ecsia/rollback': pkg('rollback'),
'@ecsia/kit': pkg('ecsia'),
'@ecsia/three': pkg('three'),
'@ecsia/react': pkg('react'),
'@ecsia/devtools': pkg('devtools'),
}
export default defineConfig({
test: {
projects: [
{
test: {
name: 'unit',
include: ['packages/*/test/**/*.test.ts', 'packages/*/src/**/*.test.ts'],
environment: 'node',
alias,
},
},
{
// @ecsia/react needs a DOM: jsdom environment + @testing-library/react. Tests are .tsx
// (the unit project's *.test.ts glob never matches them).
esbuild: { jsx: 'automatic' },
test: {
name: 'react',
include: ['packages/react/test/**/*.test.tsx'],
environment: 'jsdom',
setupFiles: ['packages/react/test/setup.ts'],
alias,
},
},
{
// The "examples run green in CI" gate: each example's main() is driven by a
// smoke test that imports ecsia and asserts the observable end state.
test: {
name: 'examples',
include: ['examples/test/**/*.test.ts'],
environment: 'node',
alias,
},
},
{
// The @ecsia/react example renders into a DOM, so its smoke test is .tsx under jsdom —
// same harness as the `react` project, reusing its act()/cleanup setup.
esbuild: { jsx: 'automatic' },
test: {
name: 'examples-react',
include: ['examples/test/**/*.test.tsx'],
environment: 'jsdom',
setupFiles: ['packages/react/test/setup.ts'],
alias,
},
},
{
// Bench self-check: the full suite runs on demand (pnpm bench:macro), but a tiny smoke test
// keeps the harness compiling + runnable in CI without paying the measurement cost.
test: {
name: 'bench',
include: ['bench/test/**/*.test.ts'],
environment: 'node',
alias,
},
},
{
// EMBER WORKS sim: determinism, element reactions, and the share-URL codec run headless
// (serial scheduler path; the threaded path is covered by the browser-smoke E2E). Each sim
// test builds a full 131k-particle pool (+ hashes every row), so the default 5s timeout is
// too tight on slower CI runners — give the project real headroom.
test: {
name: 'embers',
include: ['embers/test/**/*.test.ts'],
environment: 'node',
testTimeout: 60_000,
alias,
},
},
],
// We measure the published source only — packages/*/src — excluding tests, type-only
// fixtures, barrels, and the non-published examples/bench.
coverage: {
provider: 'v8',
include: ['packages/*/src/**/*.ts'],
exclude: [
'**/*.test.ts',
'**/*.test-d.ts',
'**/index.ts',
'**/dist/**',
'examples/**',
'bench/**',
// Worker-thread entry: runs inside a worker_threads Worker, so main-process v8 coverage
// cannot observe it. It IS execution-tested by the real WorkerPool serial-equivalence suite.
'packages/scheduler/src/workers/worker-entry.ts',
],
reporter: ['text', 'json-summary', 'json'],
// A ratchet, not a target: floors sit a few points under measured reality
// (2026-06: stmts 94.9 / branch 87.7 / fn 95.7 / lines 97.3) so only real
// erosion fails CI, never run-to-run noise. Raise them when reality rises.
thresholds: {
statements: 92,
branches: 84,
functions: 92,
lines: 95,
},
},
},
})