testing-anti-patterns
Enforce high-quality testing practices by identifying and preventing common anti-patterns like mock-testing, test-only production code, and incomplete dependency mocking.
Introduction
This skill serves as a quality gate for software testing, specifically designed to help developers and AI agents avoid common pitfalls that degrade test reliability and codebase maintainability. It is intended for any engineer who writes, maintains, or reviews automated tests, particularly in environments utilizing frameworks like Jest, Vitest, or TypeScript-based test runners. By adhering to the provided Iron Laws, users can ensure their test suite verifies actual application logic rather than fragile implementation details. The skill provides clear gate functions to guide decision-making during the testing process, ensuring that mocks are used for isolation rather than as the target of assertions.
-
Detects and prevents the testing of mock behavior instead of real system functionality.
-
Eliminates the practice of polluting production classes with test-only methods, promoting cleaner separation of concerns.
-
Provides a robust framework for understanding and mocking dependencies, preventing silent failures caused by incomplete mock responses.
-
Implements an algorithmic gate function to evaluate the necessity and correctness of mocks before they are introduced into the test suite.
-
Supports the application of strict Test-Driven Development (TDD) principles to avoid common testing anti-patterns.
-
Use this skill whenever you are writing new unit or integration tests, refactoring complex code, or when you notice flaky tests that rely heavily on mocking.
-
Before asserting on a mock object, verify the rationale against the skill's logic: if the test checks for mock existence, it should be deleted or refactored.
-
For production code cleanup, identify test-only methods and migrate them to external utility files to keep the production API lean and secure.
-
Always ensure mocks mirror the complete data structure of real API responses to avoid structural assumptions that cause downstream code breakage.
-
If a test is failing due to complex side effects, use the gate function to determine if you are mocking at the wrong level and adjust your test doubles accordingly.
Repository Stats
- Stars
- 16
- Forks
- 0
- Open Issues
- 0
- Language
- Shell
- Default Branch
- main
- Sync Status
- Idle
- Last Synced
- May 1, 2026, 08:12 AM