test-antipatterns

Detect mock-driven assertions and unsafe mocking patterns in JavaScript and TypeScript tests.

Updated May 28, 2026
One-click install
npx skills add https://github.com/haryelramalho/skills --skill test-antipatterns-haryelramalho
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-antipatterns
Source: https://github.com/haryelramalho/skills/tree/main/skills/community/test-antipatterns
Command: npx skills add https://github.com/haryelramalho/skills --skill test-antipatterns-haryelramalho

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid brittle and misleading tests by catching mock-centric assertions, unsafe over-mocking, and production code polluted with test-only methods.

Core Features & Use Cases

  • Real Behavior Verification: Ensures tests validate the actual component or system behavior instead of proving that a mock exists.
  • Dependency-Aware Mocking: Helps choose the right level to mock so tests keep the side effects they depend on.
  • Test Design Guardrails: Prevents adding lifecycle helpers to production classes and encourages test utilities instead.
  • Use Case: Review a new TypeScript test file and identify any assertions against mock elements, incomplete mock objects, or accidental test-only APIs in production code.

Quick Start

Review this test or implementation for mock misuse and suggest safer test patterns, minimal mocking, and any cleanup that should move into test utilities.

Frequently Asked Questions about test-antipatterns

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

FAQPage Schema
Why are my unit tests brittle and failing when I refactor?

Unit tests become brittle when assertions target mock interactions instead of real behavior. This Skill detects mock-driven assertions and unsafe mocking patterns, ensuring tests validate actual component behavior and remain stable during refactoring.

How do I identify unsafe mocking patterns in TypeScript test files?

You can identify unsafe mocking patterns in TypeScript test files by reviewing assertions against mock elements and incomplete mock objects. This Skill analyzes test code to detect mock-centric validations and suggests safer test patterns with minimal necessary isolation.

What is mock-driven assertion in integration tests?

Mock-driven assertion in integration tests occurs when tests verify that a mock was called rather than validating real system behavior. This Skill identifies these patterns and enforces real behavior validation with minimal mocking to prevent misleading integration test results.

How do I prevent test-only methods in production code?

To prevent test-only methods in production code, move test helpers and lifecycle methods into test utilities. This Skill detects accidental test-only APIs in production classes and enforces test utility separation to keep production code clean.

Can I use this for code review of JavaScript and TypeScript testing?

Yes, you can use this for code review of JavaScript and TypeScript testing. This Skill reviews test files and implementations to identify mock misuse, incomplete mock structures, and accidental test-only APIs, suggesting safer patterns and cleanup.

When should I not use mocks in unit tests?

You should avoid mocks in unit tests when the dependencies do not compromise test reliability. This Skill helps determine the right level to mock by enforcing minimal necessary isolation and ensuring tests keep the side effects they depend on.