Testing Anti Patterns
Use when writing or changing tests, adding mocks, or tempted to add test-only methods to production code - prevents testing mock behavior, production pollution with test-only methods, and mocking without understanding dependencies
Install
/plugin marketplace add lifangda/claude-pluginsThe repo is a Claude Code plugin marketplace. Run /plugin afterwards to pick the plugin that includes this skill.
npx skills add lifangda/claude-plugins --skill testing-anti-patternsgit clone --depth 1 https://github.com/lifangda/claude-plugins.git /tmp/claude-plugins
mkdir -p ~/.claude/skills
cp -r /tmp/claude-plugins/cli-tool/skills-library/testing-quality/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
- lifangda/claude-plugins
- Path
cli-tool/skills-library/testing-quality/testing-anti-patterns/SKILL.md- License
- MIT
- Repo updated
- 29 October 2025
FAQ
What does the Testing Anti Patterns skill do?
Use when writing or changing tests, adding mocks, or tempted to add test-only methods to production code - prevents testing mock behavior, production pollution with test-only methods, and mocking without understanding dependencies
How do I install the Testing Anti Patterns skill?
Claude Code plugin: /plugin marketplace add lifangda/claude-plugins. 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 lifangda/claude-plugins, which has 43 GitHub stars and 13 forks.
Related skills
Test Driven Development
43lifangda/claude-plugins
Use when implementing any feature or bugfix, before writing implementation code - write the test first, watch it fail, write minimal code to pass; ensures tests actually verify behavior by requiring failure first
Video Downloader
43lifangda/claude-plugins
Downloads videos from YouTube and other platforms for offline viewing, editing, or archival. Handles various formats and quality options.
Aeon
43lifangda/claude-plugins
Time series machine learning toolkit for classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use this skill when working with temporal data, performing time series analysis, building predictive models on sequential data, or implementing workflows that involve distance metrics (DTW), transformations (ROCKET, Catch22), or deep learning for time series. Applicable for tasks like ECG classification, stock price forecasting, sensor anomaly detection, or activity recognition from wearable devices.
Testing Skills with Subagents
43lifangda/claude-plugins
Use when creating or editing skills, before deployment, to verify they work under pressure and resist rationalization - applies RED-GREEN-REFACTOR cycle to process documentation by running baseline without skill, writing to address failures, iterating to close loopholes
Defense in Depth
43lifangda/claude-plugins
Use when invalid data causes failures deep in execution, requiring validation at multiple system layers - validates at every layer data passes through to make bugs structurally impossible
Browser Testing
49UCSB-NLP-Chang/Skill-Usage
VERIFY your changes work. Measure CLS, detect theme flicker, test visual stability, check performance. Use BEFORE and AFTER making changes to confirm fixes. Includes ready-to-run scripts: measure-cls.ts, detect-flicker.ts
Browse the most popular Claude skills, all testing & qa skills, or write your own with the skills generator.