# testing

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.

- rule · `type=rule` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline · ★ 1064 repo stars
- Author: jarrodwatts
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/jarrodwatts/claude-code-config/tree/HEAD/rules/testing.md
- Updated: 2026-01-21
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/rules/jarrodwatts-testing

## What it 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.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/rules/testing.md` — The paths frontmatter field limits the files

### Codex

**AGENTS.md**
- Codex reads AGENTS.md: paste the rule text there

### Cursor

**Manually: put the files in place**
- File: `.cursor/rules/testing.mdc` — Frontmatter: description, globs, alwaysApply

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/instructions/testing.instructions.md` — The applyTo field sets which files it applies to

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/rules/testing.md`

### Cline

**Manually: put the files in place**
- File: `.clinerules/testing.md`

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/jarrodwatts/claude-code-config/tree/HEAD/rules/testing.md

## When to use it
- 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
- Apply the `testing` rule to `UserService` tests and cover a successful lookup.
- Add tests for an API failure and an empty result, following the `testing` rule.
- Check that mocks are reset between tests under `__tests__`.

## Similar
- [caliber-testing](https://affpapa.org/en/nevibecode/skills/caliber-testing.md) — skill · ★ 1319 repo stars
- [testing-boss](https://affpapa.org/en/nevibecode/skills/testing-boss.md) — skill · 274 installs
- [testing-patterns](https://affpapa.org/en/nevibecode/rules/testing-patterns.md) — rule · ★ 1319 repo stars
- [safe-extraction](https://affpapa.org/en/nevibecode/skills/safe-extraction.md) — skill · ★ 539 repo stars
- [writing-tests](https://affpapa.org/en/nevibecode/skills/zaxbyhub-writing-tests.md) — skill · ★ 539 repo stars
- [e2e-testing](https://affpapa.org/en/nevibecode/skills/e2e-testing.md) — skill · 7200 installs

## Other versions with the same name
- [testing · caliber-ai-org](https://affpapa.org/en/nevibecode/rules/testing.md) — ★ 1319 repo stars
- [testing · sangrokjung](https://affpapa.org/en/nevibecode/rules/sangrokjung-testing.md) — ★ 880 repo stars
- [testing · justxor](https://affpapa.org/en/nevibecode/rules/justxor-testing.md) — ★ 353 repo stars
- [testing · aaronontheweb](https://affpapa.org/en/nevibecode/rules/aaronontheweb-testing.md) — ★ 138 repo stars

From the same set: [jarrodwatts/claude-code-config](https://affpapa.org/en/nevibecode/by/jarrodwatts/claude-code-config.md) — 20 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
