Design regression tests with mocked data in Claude Code
Use isolated tests with simulated dependencies for successful behavior, input edges, and external failures.
中文Install in Claude Code
A Claude Code project with an existing test framework. This example uses a local preview workflow with a test double.
- Review `.claude/skills/test-writer/SKILL.md` and its requirements at the pinned GitHub commit.
- Create `.claude/skills/test-writer/` in your project and save the reviewed file as `.claude/skills/test-writer/SKILL.md`.
- Start Claude Code from that project's root, then select `/test-writer` in the slash menu.
Example task
Test a component that reads an event preview. Mock the success response as `{rows:['Hall','Garden'],status:'ok'}`, a timeout, and an empty reply. Give each case fixed data.What to check
Assert success renders `['Hall','Garden']`. For the empty reply, check the visible empty state. For a timeout, assert a retry action appears. Arrange, trigger, and assert separately in each test.
Original SKILL.md on GitHub · Updated
Frequently asked question
How can I verify a timeout screen without a third-party request?
Have the test double produce the timeout and trigger the real component logic. Check the visible failure state or retry action.