Skip to content

fix(test): exclude .claude/ from jest + polyfill TextEncoder for jsdom (#488, #489) - #502

Merged
jonathonbyrdziak merged 1 commit into
mainfrom
hb/test-health-jest
Jul 22, 2026
Merged

fix(test): exclude .claude/ from jest + polyfill TextEncoder for jsdom (#488, #489)#502
jonathonbyrdziak merged 1 commit into
mainfrom
hb/test-health-jest

Conversation

@jonathonbyrdziak

Copy link
Copy Markdown
Contributor

Turns two fully-specced but never-shipped autonomous-cycle issues (#488, #489) into a PR. Both are additive test-health fixes with no behavior change to real suites.

#488 — exclude .claude/ from jest

yarn test:unit:jest on clean main was slow, non-deterministic, and noisy because jest walks into .claude/worktrees/agent-* — stale registered git worktrees left behind by Claude Code agents. Each is a full repo copy, so jest discovered and ran ~163 phantom duplicate suites and OOM-killed a worker (SIGKILL), burying real failures.

Fix: add <rootDir>/.claude to both modulePathIgnorePatterns (haste-map module/mock collisions) and testPathIgnorePatterns (test discovery). .claude/ is already gitignored → local-run-only impact, but every agent/dev who ever created a worktree hits it.

#489 — polyfill TextEncoder/TextDecoder for jsdom

The jsdom testEnvironment doesn't expose TextEncoder/TextDecoder as globals, but pg references them at import time. Any suite loading a DB model crashed with ReferenceError: TextEncoder is not defined before a single test ran.

Fix: new guarded setupTextEncoder.ts assigns them from node:util onto globalThis (no-op where already defined), registered first in setupFiles (before setupVue) so it runs before any pg import.

Verification (this PR, in an isolated worktree off main)

  • SullaSettingsModel.simple.test.ts: 0 → 2 passing.
  • jest --listTests config valid (70 suites); a planted .claude/worktrees/agent-decoy test is correctly ignored (0 discovered though present on disk).
  • tsc --noEmit --isolatedModules clean on the new file.

Diff: 2 files, +22 −0.

Closes #488
Closes #489

🤖 Generated with Claude Code during an autonomous heartbeat cycle.

Two additive test-health fixes with no behavior change to real suites.

#488 — jest walks into .claude/worktrees/agent-* (stale registered git
worktrees left by Claude Code agents), discovering ~163 phantom duplicate
suites and OOM-killing a worker. Add <rootDir>/.claude to both
modulePathIgnorePatterns (haste-map collisions) and testPathIgnorePatterns
(test discovery). .claude/ is already gitignored, so local-only impact.

#489 — jsdom testEnvironment does not expose TextEncoder/TextDecoder, but pg
references them at import time, so any suite loading a DB model crashed with
'ReferenceError: TextEncoder is not defined' before running. New guarded
setupTextEncoder.ts assigns them from node:util onto globalThis, registered
first in setupFiles (before setupVue) so it runs before any pg import.

Verified: SullaSettingsModel.simple.test.ts 0->2 passing; jest --listTests
valid (70 suites) with a planted .claude decoy correctly ignored; tsc clean.

Closes #488, closes #489

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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