eng-testing-anti-patterns
Installation
SKILL.md
Testing Anti-Patterns
Overview
Tests must validate real behavior, not mock behavior. Mocks are isolation tools; they are never the subject under test. Follow these guardrails whenever you touch tests or mocks.
Iron Laws
1. NEVER test mock behavior
2. NEVER add test-only methods to production classes
3. NEVER mock without understanding dependencies
4. NEVER ship incomplete mocks
5. NEVER treat integration tests as an afterthought
Anti-Pattern 1: Testing Mock Behavior
- ❌ Example: asserting
getByTestId('sidebar-mock')exists after mocking<Sidebar/>. - Why wrong: proves mock works, says nothing about component.
- ✅ Fix: test the real component (or mock only for isolation but assert behavior, not mock internals).