testing-anti-patterns

Detect testing anti-patterns in JavaScript/TypeScript unit and integration tests.

21|2|Updated Oct 26, 2025
One-click install
npx skills add https://github.com/amrhas82/agentic-toolkit --skill testing-anti-patterns-amrhas82
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/amrhas82/agentic-toolkit/tree/main/ai/subagents/claude/skills/testing-anti-patterns
Command: npx skills add https://github.com/amrhas82/agentic-toolkit --skill testing-anti-patterns-amrhas82

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers avoid common mistakes in testing that lead to unreliable tests, polluted production code, and a false sense of security. It ensures your tests truly validate real behavior, not just mock interactions, saving you from debugging issues that tests should have caught.

Core Features & Use Cases

  • Identify Mocking Errors: Guides you to prevent testing mock behavior instead of real code, ensuring meaningful test coverage and preventing false positives.
  • Prevent Production Pollution: Advises against adding test-only methods to production code, maintaining clean separation of concerns and reducing accidental side effects.
  • Use Case: When reviewing a pull request with new tests, apply this skill to identify if any tests are asserting on mock internals or if test-specific code has crept into the main application logic, ensuring high-quality contributions.

Quick Start

Review the attached test file 'user-service.test.ts' for common testing anti-patterns.

Frequently Asked Questions about testing-anti-patterns

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

FAQPage Schema
How do I identify mock usage mistakes in my JavaScript tests?

Mock usage mistakes occur when tests assert on mock behavior rather than real code. Detect these by reviewing test assertions—if you're verifying that a mock was called instead of validating actual application logic, your test is testing the mock, not production code. This creates false confidence and misses real bugs.

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

Test-only methods pollute production code and violate separation of concerns, creating accidental side effects and maintenance debt. Keep production and test logic completely separate. If you need to test internal behavior, redesign the code or test through public interfaces instead.

What are the common testing anti-patterns in unit and integration tests?

Common anti-patterns include testing mock interactions instead of real behavior, over-mocking dependencies without understanding them, and embedding test-specific code in production. These undermine test reliability and create false positives, letting real bugs slip through.

How do I review pull requests for testing issues?

When reviewing tests, check if assertions verify mock internals or real outcomes, inspect production code for test-only methods, and ensure mocks serve actual isolation needs. Apply these checks to catch quality issues before merging.

Can I use this for TypeScript as well as JavaScript projects?

Yes, this skill applies to both JavaScript and TypeScript projects. The anti-patterns—mock behavior testing, production pollution, and over-mocking—are language-agnostic and affect test reliability equally in both ecosystems.

What's the difference between meaningful mocking and anti-patterns?

Meaningful mocking isolates units to test specific behavior while understanding dependencies. Anti-patterns mock without purpose, test mock internals instead of real code, or add test-specific methods to production. Understanding your dependencies prevents anti-patterns.

Related Skills