fix(test): exclude .claude/ from jest + polyfill TextEncoder for jsdom (#488, #489) - #502
Merged
Merged
Conversation
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>
This was referenced Jul 22, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 jestyarn test:unit:jeston cleanmainwas 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>/.claudeto bothmodulePathIgnorePatterns(haste-map module/mock collisions) andtestPathIgnorePatterns(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
jsdomtestEnvironment doesn't exposeTextEncoder/TextDecoderas globals, butpgreferences them at import time. Any suite loading a DB model crashed withReferenceError: TextEncoder is not definedbefore a single test ran.Fix: new guarded
setupTextEncoder.tsassigns them fromnode:utilontoglobalThis(no-op where already defined), registered first insetupFiles(beforesetupVue) so it runs before anypgimport.Verification (this PR, in an isolated worktree off
main)SullaSettingsModel.simple.test.ts: 0 → 2 passing.jest --listTestsconfig valid (70 suites); a planted.claude/worktrees/agent-decoytest is correctly ignored (0 discovered though present on disk).tsc --noEmit --isolatedModulesclean on the new file.Diff: 2 files, +22 −0.
Closes #488
Closes #489
🤖 Generated with Claude Code during an autonomous heartbeat cycle.