Claude Code Testing Patterns Skill for Jest Data Factories
Use factories with defaults and targeted overrides to set up Jest behavior tests. Focus assertions on what users observe.
中文Install in Claude Code
Use Claude Code with the pinned skill and a Jest project. React tests also need the project's Testing Library setup.
- Get the complete `cli-tool/components/skills/development/testing-patterns` directory from the pinned GitHub checkout.
- Copy it under the target project's `.claude/skills/`. Confirm `.claude/skills/testing-patterns/SKILL.md`, open Claude Code at the project root, and call `/testing-patterns`.
Example task
Test a fictional event list's Cancel button. The factory defaults to a cancelable event. Override it as ended in a second case, then query the button by role and check each enabled state.What to check
Both cases share a factory. Only the ended case overrides the relevant field, and assertions inspect visible button behavior.
Original SKILL.md on GitHub · Updated
Frequently asked question
Should every test repeat the full event object?
Put unrelated defaults in the factory. Override only fields relevant to the assertion so the purpose of each test stays visible.