Testing-Anti-Patterns

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

149|10|Updated Oct 30, 2025
One-click install
npx skills add https://github.com/tilework-tech/nori-profiles --skill testing-anti-patterns-tilework-tech
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Testing-Anti-Patterns
Source: https://github.com/tilework-tech/nori-profiles/tree/main/src/installer/features/profiles/config/_mixins/_swe/skills/testing-anti-patterns
Command: npx skills add https://github.com/tilework-tech/nori-profiles --skill testing-anti-patterns-tilework-tech

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents common testing anti-patterns, ensuring your tests verify real code behavior, avoid polluting production code with test-only methods, and use mocks effectively, leading to more reliable and maintainable test suites.

Core Features & Use Cases

  • Mock Behavior Prevention: Guides against testing mock existence, focusing tests on actual component behavior.
  • Production Code Purity: Enforces keeping test-only methods out of production classes, maintaining clean architecture.
  • Intelligent Mocking: Teaches how to mock only when necessary and at the correct level, preserving essential side effects.
  • Use Case: When reviewing a new test suite, use this skill to identify and correct anti-patterns like over-mocking or testing mock internals, ensuring the tests provide true confidence in the code.

Quick Start

I'm writing a new test. Help me avoid 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 avoid testing mock behavior instead of real code behavior?

Testing mock behavior defeats the purpose of unit tests. Focus assertions on actual component outputs and side effects, not on whether mocks were called or exist. Verify real behavior by testing against actual dependencies or minimal stubs that preserve essential interactions.

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

Test-only methods pollute production code, obscure real APIs, and create maintenance burden. Keep production classes clean by testing through public interfaces only. If you need special test hooks, reconsider your test design or use dependency injection instead.

When should I use mocks in unit and integration tests?

Mock only external dependencies—APIs, databases, file systems—where you need to isolate behavior or control side effects. Never mock the code under test. Understand what each dependency does before mocking it; mocking without that knowledge leads to tests that pass but hide real bugs.

How do I write tests that verify real behavior instead of implementation details?

Tests should assert on observable outcomes—return values, state changes, side effects—not internal mock calls or test-specific conditions. Write complete, behavior-focused tests that would catch actual breakage in production, not just changes to how mocks are configured.

What are common testing anti-patterns in TypeScript and JavaScript codebases?

Common anti-patterns include testing mock existence, adding test-only methods to production, over-mocking without understanding dependencies, and testing implementation instead of behavior. These weaken confidence in tests and leak test concerns into production code.

How do I maintain and refactor tests without introducing anti-patterns?

During maintenance, remove test-only methods, replace unnecessary mocks with real implementations or minimal stubs, and ensure assertions target actual behavior. Refactor tests to stay focused on verifiable outcomes, applying the Iron Laws consistently as code evolves.