Repository navigation
Expand file tree
/
Copy pathvitest.config.mts
More file actions
102 lines (101 loc) · 4.33 KB
/
Copy pathvitest.config.mts
File metadata and controls
102 lines (101 loc) · 4.33 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
import { fileURLToPath } from 'node:url';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { defineConfig } from 'vitest/config';
import { WASM_RUNTIME_FLAGS } from './src/extraction/wasm-runtime-flags';
/**
* One process, two Vitest projects. The engine stays in Node; the UI package
* test alone gets Svelte compilation, jsdom and browser resolution conditions.
*/
export default defineConfig({
test: {
globals: true,
environment: 'node',
include: ['__tests__/**/*.test.ts'],
// Suites that spawn the built CLI need a current dist/ (#1879), and the end
// of the run removes any home sandbox its own test file could not.
globalSetup: ['./__tests__/global-setup-dist.ts', './__tests__/global-setup-home-sandbox.ts'],
// A throwaway home dir (and git global config) per test file, so nothing
// the suite runs can write to the developer's real one (#2275).
setupFiles: ['./__tests__/setup-home-sandbox.ts'],
/**
* Since Vitest 3 a synchronous test or hook fails when it outlasts its
* timeout. Under Vitest 2 the timer could not fire until the body had
* returned, so a body blocked in `spawnSync` never timed out at all. Hundreds
* of tests here block on the built CLI, and on a loaded machine the 5 s and
* 10 s defaults would turn them into flakes.
*/
testTimeout: 30_000,
hookTimeout: 60_000,
env: {
/**
* The suite spawns real CLI/MCP processes; without this they would write
* telemetry state into the contributor's real ~/.codegraph and count test
* tool calls as real usage. The telemetry unit tests are unaffected —
* they inject their own `env` via the Telemetry constructor.
*/
CODEGRAPH_TELEMETRY: '0',
},
/**
* The same V8 flags every real launch path passes (the bundled launcher,
* the CLI's self re-exec, refresh-launcher): keep tree-sitter grammar
* compilation on the Liftoff baseline tier. Without them a pool worker
* runs the grammars on the turboshaft optimizing tier, and once enough
* parses have warmed a grammar function up, its background tier-up job
* exhausts a compiler Zone and aborts the worker — `Fatal process out of
* memory: Zone`, surfaced by vitest only as "Worker exited unexpectedly"
* with the rest of the file's tests silently unrun (#1779, #1883; the
* product-side story is in wasm-runtime-flags.ts, #293/#298). V8 flags are
* process-global, so the parse worker threads a test spawns are covered
* too. Vitest 4 reads `test.execArgv`; the 2.x `poolOptions.forks.execArgv`
* is silently ignored here. The engine project inherits it via `extends`.
*/
execArgv: [...WASM_RUNTIME_FLAGS],
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
},
projects: [
{
extends: true,
test: {
name: 'engine',
include: ['__tests__/**/*.test.ts'],
// A lazy `require` of a `.ts` file can't run under vitest's module
// transform: see src/lazy-engine.ts.
alias: [
{
find: /^\.\/lazy-engine$/,
replacement: fileURLToPath(new URL('./__tests__/lazy-engine-eager.ts', import.meta.url)),
},
{
find: /^\.\/lazy-frameworks$/,
replacement: fileURLToPath(new URL('./__tests__/lazy-frameworks-eager.ts', import.meta.url)),
},
],
exclude: ['**/node_modules/**', '**/dist/**', '__tests__/ui-package.test.ts'],
},
},
{
// Browser package resolution must not leak into the engine project:
// web-tree-sitter and other dual packages would resolve differently.
// And no `extends`: a project that extends takes the base's `include`
// too, so every engine suite would run a second time inside jsdom.
extends: false,
plugins: [svelte({ configFile: 'ui/svelte.config.js' })],
resolve: { conditions: ['browser'] },
test: {
name: 'ui',
globals: true,
include: ['__tests__/ui-package.test.ts'],
environment: 'jsdom',
server: {
deps: {
// @xyflow/svelte ships source .svelte files that Node cannot load.
inline: [/@xyflow\/svelte/],
},
},
},
},
],
},
});