testing-anti-patterns

Prevent testing anti-patterns in test suites by enforcing core constraints.

Updated Oct 22, 2025
One-click install
npx skills add https://github.com/franroa/chezmoi --skill testing-anti-patterns-franroa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/franroa/chezmoi/tree/main/dot_opencode/superpowers/skills/testing-anti-patterns
Command: npx skills add https://github.com/franroa/chezmoi --skill testing-anti-patterns-franroa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid common pitfalls that lead to ineffective, brittle, or misleading tests. It prevents you from testing mock behavior, polluting production code with test-only methods, and creating incomplete or misunderstood mocks.

Core Features & Use Cases

  • Mock Behavior Prevention: Guides you to test real code behavior, not just the existence or functionality of your mocks.
  • Production Code Purity: Ensures test-only methods don't creep into your production classes, maintaining clean separation of concerns.
  • Dependency Understanding: Forces you to understand dependencies before mocking, preventing tests that pass for the wrong reasons.
  • Use Case: When writing new tests or refactoring existing ones, consult this Skill to ensure your tests are robust. For example, if you're tempted to assert on a mock's internal state, this Skill will redirect you to test the actual component's behavior.

Quick Start

Announce skill usage

I'm using the testing-anti-patterns skill to review my test strategy.

The skill will then guide you through common pitfalls and their fixes.

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 means asserting on mock calls rather than actual component outcomes. Test the real code's behavior by verifying its output, state changes, or side effects, not whether the mock was invoked. This ensures tests catch real defects, not just mock configuration.

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

Test-only methods pollute production classes and violate separation of concerns. Instead, refactor production code into testable units, use dependency injection, or adjust test structure. Clean production code is easier to maintain and doesn't leak testing concerns into runtime logic.

What does it mean to mock without understanding dependencies?

Mocking without understanding dependencies creates tests that pass for wrong reasons—they test the mock's behavior, not the real dependency contract. Before mocking, understand what the dependency does, its inputs and outputs, and how your code uses it. This prevents brittle, misleading tests.

How do I know if my unit tests are effective?

Effective unit tests verify real behavior, not mock existence. They fail when production code breaks, not when mocks change. Avoid asserting on mock state; instead verify your component's actual output, side effects, or error handling match expectations.

When should I refactor existing tests for better coverage?

Refactor tests when they pass despite broken production code, rely heavily on mocks, or include test-only production methods. Use this skill when writing new tests or updating existing ones to ensure they catch real defects and remain maintainable as code evolves.