Skip to content

fix(test): exclude .claude/ from jest scanning (kills ~163 phantom worktree suites + OOM) - #488

Closed
jonathonbyrdziak wants to merge 1 commit into
mainfrom
fix/jest-ignore-claude-worktrees
Closed

fix(test): exclude .claude/ from jest scanning (kills ~163 phantom worktree suites + OOM)#488
jonathonbyrdziak wants to merge 1 commit into
mainfrom
fix/jest-ignore-claude-worktrees

Conversation

@jonathonbyrdziak

Copy link
Copy Markdown
Contributor

Problem

yarn test:unit:jest on a clean main checkout is slow, non-deterministic, and noisy. Root cause: jest walks into .claude/worktrees/agent-* — stale registered git worktrees left behind by Claude Code agents (April/June snapshots, on old branches feat/token-ws3-slim-tool-catalog and worktree-agent-ac361fc4). Each is a full copy of the repo tree, so jest discovers and runs their test files as if they were part of the working tree.

Measured impact on this machine (node --experimental-vm-modules .../jest.js, no filters):

before after
total suites scanned 231 68
runtime 59 s + a jest worker OOM-killed (SIGKILL) 18 s
phantom .claude/worktrees suites ~163 0

The SIGKILL made runs non-deterministic (a worker dies mid-run) and the ~163 duplicate suites buried the real failures.

Fix

Add <rootDir>/.claude to both ignore lists in jest.config.js:

  • modulePathIgnorePatterns — stops haste-map module/mock collisions from the duplicated trees
  • testPathIgnorePatterns — stops test discovery inside them

.claude/ is already gitignored (it's the Claude Code convention dir), so this only affects local runs — but every agent/dev who has ever created a worktree hits it. Two-line, additive, no behavior change to real tests.

Scope / not included

This is hygiene only. After the fix, 24 real-tree suites still fail — all pre-existing and environment-specific, not touched here:

  • @napi-rs/xattr-linux-arm64-musl native binding missing (arm64/musl box; fine on x64 CI)
  • missing kubectl/integration fixtures + readlink ENOENT under /tmp
  • ReferenceError: TextEncoder is not defined when pg is imported under the jsdom test environment (3 suites — a genuine cross-env bug worth a follow-up, but out of scope for this PR)

Note for whoever's chasing the "jest fails on clean branch" report: the earlier "missing babel-preset-expo" theory is a red herring — this repo has no Expo/babel-preset-expo dependency at all (Electron/Vue/Babel toolchain); grep babel-preset-expo over the whole jest log returns 0.

🤖 Generated with Claude Code

Jest was walking into `.claude/worktrees/agent-*` — stale registered git
worktrees left by Claude Code agents (April/June snapshots on old branches).
Because each is a full copy of the repo tree, jest ran ~163 phantom duplicate
suites, which:

- tripled runtime (59s -> 18s after this change)
- OOM-killed a jest worker (SIGKILL), making the whole run non-deterministic
- buried the real ~24 failing suites in noise (231 -> 68 total suites)

`.claude/` is gitignored (Claude Code convention dir) so this only affects
local runs, but every agent/dev using worktrees hits it. Added `<rootDir>/.claude`
to both modulePathIgnorePatterns (haste-map collisions) and testPathIgnorePatterns
(test discovery).

Scope: hygiene only. The 24 remaining real-tree failures are pre-existing and
environment-specific (arm64-musl @napi-rs/xattr binding, missing kubectl fixtures,
TextEncoder-under-jsdom) — untouched here.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jonathonbyrdziak

Copy link
Copy Markdown
Contributor Author

PR opened: #502 (autonomous heartbeat cycle). Fix applied and verified in an isolated worktree off main; see the PR for the verification run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant