testing-anti-patterns

Prevent testing anti-patterns in unit, integration, and UI test suites.

Updated Nov 3, 2025
One-click install
npx skills add https://github.com/ayourtch/kimichat --skill testing-anti-patterns-ayourtch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/ayourtch/kimichat/tree/main/skills/testing-anti-patterns
Command: npx skills add https://github.com/ayourtch/kimichat --skill testing-anti-patterns-ayourtch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents common mistakes that lead to brittle, ineffective, or misleading tests, ensuring your test suite provides real value and confidence in your codebase.

Core Features & Use Cases

  • Mock Behavior Avoidance: Guides against testing mocks instead of actual code behavior, ensuring tests verify real functionality.
  • Production Code Purity: Prohibits adding test-only methods to production classes, keeping your codebase clean and focused.
  • Dependency Understanding: Emphasizes understanding dependencies before mocking to prevent unintended side effects and mysterious test failures.
  • Use Case: When reviewing a new test that asserts on a mock's internal state, use this skill to identify if it's testing mock behavior rather than the component's actual functionality.

Quick Start

I'm using the testing-anti-patterns skill to review the new user-service.test.ts file for common mistakes.

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 mocks instead of actual code behavior?

Testing mocks instead of actual behavior happens when assertions check mock internal state rather than real functionality. Focus assertions on the component's actual output and side effects, not whether the mock was called or how it was configured. Verify real behavior by testing the actual dependency interactions.

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

Test-only production methods bloat your codebase and create maintenance confusion between test and production concerns. Keep production classes focused on their actual business logic. Instead, refactor code to be naturally testable or use dependency injection to control behavior during testing.

What's the best way to mock dependencies safely?

Safe mocking starts by understanding what the dependency does and why you're replacing it—don't mock without clarity on its behavior and contracts. Complete mocks that capture the full interface reduce mysterious test failures. Verify your mocks match real dependency behavior to catch integration issues early.

How do I write tests that provide real confidence in my code?

Tests gain confidence by verifying actual component behavior against real dependencies, not mock implementations. Avoid assertions on mock state; test observable outputs and side effects instead. Use gate-based testing—check preconditions, execute the action, verify results—to ensure tests reflect real usage patterns.

When reviewing tests, how do I spot testing anti-patterns?

Look for assertions on mock call counts or configurations, test-only methods in production classes, and mocks used without understanding the dependency. Check that tests verify real functionality, not implementation details. Refactor tests that assert on mocks to verify actual component behavior instead.