testing-anti-patterns

Detect testing anti-patterns that pollute production code and test suites.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/chriscarterux/chris-claude-stack --skill testing-anti-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/chriscarterux/chris-claude-stack/tree/main/skills/testing-anti-patterns
Command: npx skills add https://github.com/chriscarterux/chris-claude-stack --skill testing-anti-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid common mistakes that lead to brittle, ineffective, or misleading tests. It ensures your tests verify actual code behavior, not just mock interactions, preventing false confidence, wasted effort, and future regressions in your testing strategy.

Core Features & Use Cases

  • Prevent Mock Behavior Testing: Learn to assert on real component behavior rather than the existence or actions of mocks, ensuring tests are meaningful and robust.
  • Avoid Production Pollution: Keep your production codebase clean by preventing the introduction of methods or code used solely for testing purposes.
  • Strategic Mocking: Understand when and how to mock dependencies effectively, ensuring isolation without breaking the test's logic or assumptions about real-world interactions.
  • Use Case: You're writing a test for a Page component that uses a Sidebar. Instead of asserting that a sidebar-mock exists, this skill guides you to either test the real Sidebar behavior or, if mocking, to test the Page's interaction with the Sidebar's expected output, not the mock itself.

Quick Start

BAD: Testing that the mock exists

test('renders sidebar', () => { render(<Page />); expect(screen.getByTestId('sidebar-mock')).toBeInTheDocument(); });

GOOD: Test real component or don't mock it

test('renders sidebar', () => { render(<Page />); expect(screen.getByRole('navigation')).toBeInTheDocument(); });

Frequently Asked Questions about testing-anti-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid testing mock behavior instead of real code?

Testing mock behavior—asserting that mocks exist or were called—creates false confidence without verifying actual functionality. Instead, assert on real component output or behavior, or test how your code handles the mock's expected interactions, ensuring tests validate genuine code paths.

Why shouldn't I add test-only methods to production code?

Test-only production methods pollute your codebase, create maintenance burden, and expose internal implementation details. Keep tests isolated from production by using mocks at appropriate boundaries or refactoring to make real behavior testable without special hooks.

When should I use mocks in unit testing?

Mock external dependencies—APIs, databases, file systems—to isolate the code under test. Mock at boundaries where your code interacts with services outside its control, but verify your code's real behavior when handling the mock's output, not the mock interaction itself.

What's the difference between testing mock interactions and testing real behavior?

Testing mock interactions checks if a mock was called; testing real behavior verifies your code produces correct output or side effects. Real behavior testing catches actual bugs; mock-only tests pass even when production code fails, masking regressions.

How do I write integration tests without mocking everything?

Integration tests exercise real components together, mocking only external systems your code doesn't control. Test the Page component with a real Sidebar by checking actual DOM output, not mock presence—this catches real integration failures unit tests miss.

What are common test anti-patterns I should avoid?

Common anti-patterns include asserting on mock existence, adding test helper methods to production, mocking internal dependencies, and writing tests that pass but don't verify real behavior. These mask bugs and create brittle, misleading test suites that give false confidence.