testing-anti-patterns

Detect and prevent testing anti-patterns in JavaScript/TypeScript test suites.

4|1|Updated Oct 29, 2025
One-click install
npx skills add https://github.com/samjhecht/wrangler --skill testing-anti-patterns-samjhecht
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/samjhecht/wrangler/tree/main/skills/testing-anti-patterns
Command: npx skills add https://github.com/samjhecht/wrangler --skill testing-anti-patterns-samjhecht

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Common testing mistakes like testing mock behavior, polluting production code with test-only methods, or using incomplete mocks lead to unreliable, brittle tests and false confidence in your codebase.

Core Features & Use Cases

  • Mock Behavior Prevention: Guides you to test real component behavior, not just the existence or functionality of mocks.
  • Production Code Purity: Prohibits adding test-only methods to production classes, maintaining clean separation of concerns.
  • Smart Mocking: Teaches how to mock minimally and completely, ensuring tests accurately reflect real-world dependencies.
  • Use Case: When writing new tests, modifying existing ones, or encountering flaky test suites, this skill helps you avoid common pitfalls and write robust, meaningful tests that truly verify behavior.

Quick Start

I'm writing a test for a new component that uses a mocked API. What anti-patterns should I avoid?

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 component behavior?

Testing mock behavior verifies only that mocks exist or function, not that your component works correctly. Test real behavior by asserting on component output, state changes, or side effects—not on mock call counts or arguments. This ensures tests catch actual bugs.

Why are flaky tests often caused by incomplete mocks?

Incomplete mocks leave gaps between test assumptions and real dependencies, causing tests to pass in isolation but fail in production. Mock completely by understanding all dependency interactions, then verify your component handles real-world responses and edge cases consistently.

Can I add test-only methods to production code?

No. Test-only methods pollute production code, break encapsulation, and hide real behavior from actual users. Keep production classes clean by testing through public APIs and refactoring to expose necessary internals if needed for legitimate reasons.

What's the best way to write tests that verify real behavior, not implementation details?

Test what users see and experience—component output, UI state, accessibility features, and observable side effects—rather than internal logic or structure. This makes tests resilient to refactoring and catches actual breaks in functionality.

How do I prevent test-driven production code changes from breaking real behavior?

Never mock without understanding what dependencies do and why. Write tests against genuine behavior contracts, cover all UI states including accessibility, and avoid implementation-detail assertions. This catches regressions before production.