Testing Anti Patterns

Never test mock behavior. Never add test-only methods to production classes. Understand dependencies before mocking.

43 stars 26 forksTesting & QA

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add obra/clank --skill Testing Anti-Patterns
Manual install
git 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-Patterns

Personal 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 Function
Read the full skill on GitHub

Details

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

Browse the most popular Claude skills, all testing & qa skills, or write your own with the skills generator.