Claude Code testing-patterns for isolated Jest edge cases
Use the red, green, refactor sequence and prepare isolated Jest cases with explicit expected results.
中文Install in Claude Code
Use Claude Code with a TypeScript project configured for Jest and the real logic under test. Isolate mutable state and clean up timers or test doubles afterwards.
- Review `.claude/skills/testing-patterns/SKILL.md` and its requirements at the pinned GitHub commit.
- Create `.claude/skills/testing-patterns/` in your project and save the reviewed file as `.claude/skills/testing-patterns/SKILL.md`.
- Start Claude Code from that project's root, then select `/testing-patterns` in the slash menu.
Example task
The samples-17 function sums the durations of valid video clips. Use {clipDurations: [4, 6], emptyDurations: []}.What to check
Expect 10 for the two clips and 0 for an empty list. Use independent tests that report {joinedDuration: 10, emptyDuration: 0}.
Original SKILL.md on GitHub · Updated
Frequently asked question
Should internal calls all be mocked too?
Focus on external dependencies. Exercise the actual logic under test, initialize state independently, and compare outputs directly.