testing-anti-patterns

Identify and rectify testing anti-patterns in JavaScript/TypeScript codebases.

2.5k|134|Updated Mar 28, 2026
One-click install
npx skills add https://github.com/compozy/compozy --skill testing-anti-patterns-compozy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/compozy/compozy/tree/main/.agents/skills/testing-anti-patterns
Command: npx skills add https://github.com/compozy/compozy --skill testing-anti-patterns-compozy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Tests often fall into anti-patterns that hide real behavior, leading to fragile, brittle, and hard-to-maintain suites. This guide helps teams spot and fix these issues to ensure tests verify actual code behavior rather than mocks or production pollution.

Core Features & Use Cases

  • Enforces best practices like never testing mock behavior, never adding test-only methods to production classes, and understanding dependencies before mocking.
  • Guides refactors to replace brittle test patterns with behavior-focused tests across unit and integration tests.
  • Useful during code reviews, refactoring, and test-suite consolidation to improve reliability and maintainability.

Quick Start

Audit your existing tests and rework them to validate real behavior, removing test-only production code and simplifying mocks.

Frequently Asked Questions about testing-anti-patterns

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

FAQPage Schema
How do I fix brittle unit tests that verify mock behavior instead of real code?

To fix brittle unit tests verifying mock behavior, audit your suite to ensure tests validate actual production outputs rather than mock interactions. Remove test-only methods from production classes and simplify mocks to focus on real behavior verification.

What are common testing anti-patterns in JavaScript and TypeScript codebases?

Common testing anti-patterns include adding test-only methods to production classes, testing mock behavior instead of real logic, and using incomplete mock structures. These patterns hide real behavior and create fragile, hard-to-maintain test suites.

Does this testing anti-pattern guide work for integration and end-to-end tests?

Yes, this approach works for integration and end-to-end tests. It guides refactors to replace brittle test patterns with behavior-focused tests across all test layers, reducing brittleness and improving coverage during test-suite consolidation.

When should I remove test-only production code during refactoring?

Remove test-only production code during refactoring when you audit existing tests to enforce best practices. Eliminating these methods ensures tests verify actual code behavior, reducing suite brittleness and improving overall maintainability.

Why do my unit tests break when I refactor production code dependencies?

Unit tests break during refactoring because they often rely on brittle mocks and incomplete structures rather than real behavior. Understanding dependencies before mocking and embedding tests with implementations reduces this fragility.

What is the best way to ensure complete mock structures in unit testing?

The best way to ensure complete mock structures in unit testing is to fully understand your dependencies before mocking. This practice prevents tests from hiding real behavior and maintains the reliability of your integration and unit test suites.