Testing Anti Patterns
Never test mock behavior. Never add test-only methods to production classes. Understand dependencies before mocking.
Install
npx skills add obra/clank --skill Testing Anti-Patternsgit clone --depth 1 https://github.com/obra/clank.git /tmp/clank
mkdir -p ~/.claude/skills
cp -r /tmp/clank/skills/testing/testing-anti-patterns ~/.claude/skills/Testing-Anti-PatternsPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Testing Anti-Patterns
## Overview
Tests must verify real behavior, not mock behavior. Mocks are a means to isolate, not the thing being tested.
**Core principle:** Test what the code does, not what the mocks do.
**Following strict TDD prevents these anti-patterns.**
## The Iron Laws
```
1. NEVER test mock behavior
2. NEVER add test-only methods to production classes
3. NEVER mock without understanding dependencies
```
## Anti-Pattern 1: Testing Mock Behavior
**The violation:**
```typescript
// ❌ BAD: Testing that the mock exists
test('renders sidebar', () => {
render(<Page />);
expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument();
});
```
**Why this is wrong:**
- You're verifying the mock works, not that the component works
- Test passes when mock is present, fails when it's not
- Tells you nothing about real behavior
**your human partner's correction:** "Are we testing the behavior of a mock?"
**The fix:**
```typescript
// ✅ GOOD: Test real component or don't mock it
test('renders sidebar', () => {
render(<Page />); // Don't mock sidebar
expect(screen.getByRole('navigation')).toBeInTheDocument();
});
// OR if sidebar must be mocked for isolation:
// Don't assert on the mock - test Page's behavior with sidebar present
```
### Gate FunctionDetails
- Skill name
Testing Anti-Patterns- Repository
- obra/clank
- Path
skills/testing/testing-anti-patterns/SKILL.md- Repo updated
- 9 October 2025
FAQ
What does the Testing Anti Patterns skill do?
Never test mock behavior. Never add test-only methods to production classes. Understand dependencies before mocking.
How do I install the Testing Anti Patterns skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add obra/clank --skill Testing Anti-Patterns. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Testing Anti Patterns popular?
It lives in obra/clank, which has 43 GitHub stars and 26 forks.
Related skills
Gardening Skills Wiki
43obra/clank
Maintain skills wiki health - check links, naming, cross-references, and coverage
Remembering Conversations
43obra/clank
Search previous Claude Code conversations for facts, patterns, decisions, and context using semantic or text search
Brainstorming Ideas Into Designs
43obra/clank
Interactive idea refinement using Socratic method to develop fully-formed designs
Testing Skills with Subagents
43obra/clank
RED-GREEN-REFACTOR for process documentation - baseline without skill, write addressing failures, iterate closing loopholes
Test Driven Development (TDD)
43obra/clank
Write the test first, watch it fail, write minimal code to pass
Acceptance Design
33okgrit/done-is-a-claim
Define executable acceptance for a bounded task before work or dispatch. Use when writing a worker brief, selecting success checks, or repairing an acceptance contract that cannot test the intended outcome.
Browse the most popular Claude skills, all testing & qa skills, or write your own with the skills generator.