testing-anti-patterns

Audit JavaScript/TypeScript test suites for mock-dependent assertions and anti-patterns.

Updated Jul 14, 2025
One-click install
npx skills add https://github.com/woodrowpearson/mids-hero-web --skill testing-anti-patterns-woodrowpearson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/woodrowpearson/mids-hero-web/tree/main/.claude/skills/testing-anti-patterns
Command: npx skills add https://github.com/woodrowpearson/mids-hero-web --skill testing-anti-patterns-woodrowpearson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents testing anti-patterns and provides guidance to keep tests robust, maintainable, and reliable by avoiding mock- and test-related pitfalls.

Core Features & Use Cases

  • Guidance on recognizing and avoiding common testing anti-patterns.
  • Best practices for mocking, stubbing, and test isolation to ensure real behavior is validated.
  • Use Case: A developer reviews a failing test that relies on mock behavior and refactors to verify real component behavior instead.

Quick Start

Run a quick audit of your test suite to identify mock-dependent assertions and refactor to test real behavior.

Frequently Asked Questions about testing-anti-patterns

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

FAQPage Schema
What are common JavaScript testing anti-patterns that undermine test reliability?

Testing anti-patterns that undermine reliability include asserting on mock behavior instead of real behavior, adding production test-only methods, and failing to mirror complete response structures in mocks. Avoiding these keeps JavaScript and TypeScript test suites robust and maintainable.

How do I refactor a failing unit test that relies on mock behavior?

Refactor a failing mock-dependent test by verifying real component behavior instead of mock behavior. Ensure stubs mirror complete response structures and remove production test-only methods to enforce test isolation and validate actual logic.

When should I use mocking and stubbing in unit tests?

Use mocking and stubbing in unit tests to isolate components by simulating dependencies, but never assert on mock behavior itself. Always mirror complete response structures in mocks to validate real behavior and maintain test quality across JavaScript suites.

Can I use these testing guidelines for both unit and UI tests?

Yes, these testing anti-pattern guidelines apply across JavaScript and TypeScript unit, integration, and UI tests. They provide best practices for mocking, stubbing, and test isolation to ensure real behavior is validated consistently across your entire test suite.

Why should I never add production test-only methods to my codebase?

You should never add production test-only methods because they pollute the codebase with logic used solely for testing, undermining reliability and maintainability. Instead, refactor tests to verify real behavior through proper mocking and stubbing techniques.

How do I audit my test suite for mock-dependent assertions?

Audit your test suite for mock-dependent assertions by reviewing tests that assert on mock behavior rather than real component behavior. Refactor these to mirror complete response structures in mocks, ensuring they verify actual application logic and improve test quality.