Repository navigation
Expand file tree
/
Copy pathvitest.config.ts
More file actions
135 lines (132 loc) · 6.01 KB
/
Copy pathvitest.config.ts
File metadata and controls
135 lines (132 loc) · 6.01 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
import { resolve } from 'path';
import { defineConfig } from 'vitest/config';
import {
kernelConfigs,
coverageExcludesFor,
defaultKernelId,
} from './tests/helpers/kernelRegistry.js';
/**
* Tests excluded from all kernel projects:
* - brepkit-only tests that need a real brepkit-wasm install or local link
* - cross-kernel comparison tests that manage their own dual-kernel init
* - standard non-test directories
*
* Note: brepkitAdapter.test.ts is NOT here — it drives BrepkitAdapter with a
* pure mock kernel (no WASM), so it runs in every project's gate as a unit test.
*/
const alwaysExclude = [
'tests/brepkit-adapter.test.ts',
'tests/brepkit-validation.test.ts',
'tests/kernel-agreement.test.ts',
'tests/io-stress.test.ts',
'benchmarks/**',
'node_modules/**',
'packages/**/node_modules/**',
// brepjs-cad aliases `@` to its own src and runs via its own vitest config + CI job.
'packages/brepjs-cad/**',
// brepjs-viewer likewise aliases `@`→its own src and runs via its own vitest config + CI job.
'packages/brepjs-viewer/**',
// brepjs-mesh2solid runs via its own vitest config + CI job; its tests need the
// occt-wasm mesh importer, not every kernel project.
'packages/brepjs-mesh2solid/**',
// Scaffold payload, not repo code: the template's test runs inside generated projects
// (and in the registry smoke), never against the workspace kernels.
'packages/create-brepjs/templates/**',
'apps/**',
'.worktrees/**',
// Git worktrees created under .claude/ (parallel-agent branches) carry their
// own copies of the test tree; exclude them so a stale worktree without WASM
// set up can't fail the root suite.
'.claude/worktrees/**',
];
// Default 4 — CI's sharded `test` job runs on 16 GB runners where OCCT WASM
// linear memory grows monotonically across a fork's files; more forks over-commit
// into swap and trip the per-test timeout (#1102). Overridable so a many-core,
// high-RAM machine can raise it locally without changing the CI default.
const parsedMaxWorkers = Number(process.env['VITEST_MAX_WORKERS']);
const maxWorkers =
Number.isInteger(parsedMaxWorkers) && parsedMaxWorkers > 0 ? parsedMaxWorkers : 4;
export default defineConfig({
resolve: {
alias: {
// Vite resolves the "import" exports condition by default, hitting the ESM
// bundler entry that uses the unsupported WASM ESM integration proposal.
// Alias to the Node CJS entry so brepkit tests run under vitest.
'@': resolve(import.meta.dirname, 'src'),
'brepkit-wasm': resolve(
import.meta.dirname,
'node_modules/brepkit-wasm/brepkit_wasm_node.cjs'
),
// The voxel engine ships as a committed wasm-pack artifact; point the bare
// specifier at the built ESM entry so voxel tests resolve it under vitest.
'brepjs-voxel-wasm': resolve(import.meta.dirname, 'packages/brepjs-voxel-wasm/pkg/index.js'),
// node_modules/brepjs is a stale published copy; route to live src.
brepjs: resolve(import.meta.dirname, 'src/index.ts'),
// Same for the satellite domain packages the playground-example regression
// test meshes: route to live src so tests run against current source (not
// the last-published dist) and don't need a dist build in CI.
'brepjs-sheetmetal': resolve(import.meta.dirname, 'packages/brepjs-sheetmetal/src/index.ts'),
'brepjs-bim': resolve(import.meta.dirname, 'packages/brepjs-bim/src/index.ts'),
// Subpath entries first: object-form aliases are exact-match, so the
// automatic-JSX runtime imports need their own rows (no dist in CI).
'brepjs-families/jsx-runtime': resolve(
import.meta.dirname,
'packages/brepjs-families/src/jsxRuntime.ts'
),
'brepjs-families/jsx-dev-runtime': resolve(
import.meta.dirname,
'packages/brepjs-families/src/jsxRuntime.ts'
),
'brepjs-families': resolve(import.meta.dirname, 'packages/brepjs-families/src/index.ts'),
},
},
test: {
globals: true,
setupFiles: ['./tests/setup.ts'],
testTimeout: 90000,
pool: 'forks',
// --expose-gc lets the handle-leak probes force collection so a
// FinalizationRegistry-only reclaim reads as a leak instead of passing.
execArgv: ['--max-old-space-size=6144', '--expose-gc'],
maxWorkers,
coverage: {
provider: 'v8',
include: ['src/**/*.ts'],
reporter: ['text', 'text-summary', 'lcov'],
reportsDirectory: './coverage',
// Default-kernel excludes are applied at the root because vitest's
// project-level coverage.exclude does not override the root list (yet);
// see PR description. Source of truth lives in kernelRegistry.ts (the
// default kernel) so adding/flipping a kernel doesn't require a vitest edit.
exclude: ['src/**/*.d.ts', 'src/**/index.ts', ...coverageExcludesFor(defaultKernelId())],
// Floored at the occt-wasm (default kernel) measured coverage, rounded down
// to the nearest whole percent. These are the *measured* numbers for the
// default project, not hand-tuned targets — branches at 71 is what occt-wasm
// actually achieves, not a relaxed floor. occt-wasm's adapter-dir denominator
// differs from occt's (different excluded files, different branch population),
// so the 71 is NOT comparable to the prior occt 74 floor and does not imply a
// coverage regression in shared code. Re-measure and re-floor (npm run
// test:full) if the default kernel changes.
thresholds: {
statements: 85,
branches: 71,
functions: 91,
lines: 88,
},
},
projects: kernelConfigs.map((k) => ({
extends: true,
test: {
name: k.id,
env: { TEST_KERNEL: k.id, ...(k.envOverrides ?? {}) },
exclude: [...alwaysExclude, ...(k.excludeTests ?? [])],
coverage: {
reportsDirectory: `./coverage/${k.id}`,
...(k.coverageThresholds !== 'informational' && k.coverageThresholds
? { thresholds: k.coverageThresholds }
: {}),
},
},
})),
},
});