testing · jarrodwatts — Claude Code rule: tests and installation
The testing rule sets conventions for TypeScript test files and the __tests__ directory. Use it to guide checks for success cases, failures, and edge conditions.
no license ★ 1,064 updated 2026-01-21
.claude/rules/testing.mdWhat testing does
The rule targets *.test.ts, *.spec.ts, and files under __tests__. It calls for tests organized around a setup, an action, and an expected result, with names that describe the scenario and one logical check in each test. That structure keeps cases such as UserService lookups easy to follow.
Use mocks for external APIs and databases, but keep the unit being tested real; clear mocks between tests. The rule also covers normal results, errors, empty and boundary values, plus loading, success, and error states for async code. If mocks are not reset, state can carry over between tests.
What it helps with
- organize tests around setup, action, and expected result
- name tests after the scenario they check
- isolate external APIs and databases with mocks
- cover error paths and boundary values
- check loading and result states in async code
Example prompts for the agent
- Apply the
testingrule toUserServicetests and cover a successful lookup. - Add tests for an API failure and an empty result, following the
testingrule. - Check that mocks are reset between tests under
__tests__.
How to install testing
Manually: put the files in place
.claude/rules/testing.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/testing.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/testing.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/testing.mdManually: put the files in place
.clinerules/testing.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about testing
How do I install testing in Claude Code?
Add the rule file to your project at .claude/rules/testing.md.
What does the testing rule do?
It sets conventions for test structure, mocks, and checks for failures, edge cases, and async states.
Which files does testing apply to?
It applies to *.test.ts, *.spec.ts, and files under __tests__.
Similar IDE rules
All IDE rules for Testing and QA →testing by other authors comes first.