eng-testing-anti-patterns
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).
More from tjboudreaux/cc-plugin-engineering-excellence
eng-tdd
Enforces disciplined RED-GREEN-REFACTOR cycle—write failing test first, watch it fail, write minimal code to pass, then refactor.
2eng-verification
Mandatory checklist before claiming work is complete—run the evidence-producing command, inspect output, and only then state a result.
2eng-performance
Guard latency, memory, battery, bandwidth, and gas/compute budgets by measuring before and after every change.
2eng-user-impact
Anchor every engineering decision in user value, measurable outcomes, accessibility, and cross-platform experience coherence.
2meta-superpowers
Startup protocol for every task—discover applicable skills, run them, announce usage, and follow required workflows (brainstorming, TodoWrite checklists, etc.).
2eng-observability
Design every change with traceability, diagnostics, and fast incident triage in mind across mobile, web, and web3 stacks.
2