-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathvitest.config.ts
More file actions
59 lines (58 loc) · 3.25 KB
/
Copy pathvitest.config.ts
File metadata and controls
59 lines (58 loc) · 3.25 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
import { defineConfig } from "vitest/config";
// Scope test discovery to the source tree. Without this, Vitest's default glob
// also picks up test files inside transient git worktrees under .claude/ (left
// by background agents), polluting the run.
export default defineConfig({
test: {
// Matched pair with tsconfig.json's `exclude: ["src/__tests__"]`: a test outside that tree would
// ship in dist/ yet never run here, so neither file admits one.
include: ["src/__tests__/**/*.{test,spec}.ts"],
// Redirect the home directory to a throwaway temp dir in EVERY worker
// before any module under test is imported (#879, #866). Without this the
// full suite intermittently rewrites the developer's real
// ~/.comfyui-mcp/.env and other live state — see the setup file's header.
setupFiles: ["src/__tests__/helpers/isolated-test-home.ts"],
exclude: [
"**/node_modules/**",
"**/dist/**",
"**/.git/**",
"**/.claude/**",
],
// Vitest defaults both of these to 5s, which is too tight for THIS suite on a
// loaded machine, and that produced a long-running myth of "the suite flakes in
// a rotating cast of unrelated files" (#852). It is not flaky in the usual
// sense: two full-concurrency runs on the same commit failed in almost
// disjoint sets — grok-backend + training-jobs, then node-dev,
// panel-recovery-cluster, panel-status-base-path and two training-jobs cases —
// and every one of them failed with vitest's own "If this is a long-running
// test/hook, pass a timeout value", i.e. a TIMEOUT, never an assertion. Each
// passes in isolation.
//
// WHY THIS IS NOT "WIDENING A TOLERANCE TO HIDE A RACE", which we deliberately
// refuse to do elsewhere (#821/#843 rebuilt a fixture around `listen(0)` rather
// than raising its timeout; panel #652 made an injected delay instant rather
// than lengthening the budget). Those guarded races in PRODUCT code, where a
// longer fuse leaves the bug and moves the symptom. This guards the RUNNER
// being starved of CPU: several of these tests do real work — `node-dev`
// shells out to real git — and 5s is simply not a meaningful budget for that
// when the machine is saturated. Nothing about the code under test is racy;
// the measurement apparatus was.
//
// The cost is bounded and falls only on failures: a genuinely hung test now
// takes 30s to report instead of 5s. Suite wall-clock is unchanged, because a
// passing test still returns when it returns — raising a ceiling nobody reaches
// costs nothing.
//
// If a test starts needing MORE than this, that is a signal to make it
// deterministic (inject the clock, remove the real timer), not to raise this
// number again.
// Redirect every store this app persists to at a throwaway directory for the
// whole run, BEFORE any worker forks. Four separate times a test wrote to the
// developer's real ~/.comfyui-mcp (#837, #859, #866, #879); the runtime
// guards cannot close it because they only see worker scope. See the file for
// why this is a floor rather than a replacement for them.
globalSetup: ["./vitest.global-setup.ts"],
testTimeout: 30_000,
hookTimeout: 30_000,
},
});