testing-anti-patterns

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

68|6|Updated Apr 16, 2020
One-click install
npx skills add https://github.com/zenobi-us/dotfiles --skill testing-anti-patterns-zenobi-us
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-anti-patterns
Source: https://github.com/zenobi-us/dotfiles/tree/main/devtools/files/opencode/skills/testing-anti-patterns
Command: npx skills add https://github.com/zenobi-us/dotfiles --skill testing-anti-patterns-zenobi-us

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solves? Poorly written tests can give false confidence, break easily, or test the wrong things, leading to wasted effort, undetected bugs, and unreliable test suites.

Core Features & Use Cases

  • Mock Behavior Prevention: Identifies and prevents tests from asserting on mock existence instead of real component behavior.
  • Production Code Purity: Avoids polluting production classes with test-only methods, maintaining clean separation of concerns.
  • Strategic Mocking: Guides understanding of dependencies before mocking, preventing over-mocking that breaks test logic.
  • Use Case: You're reviewing a new test suite and notice assertions on mock elements. Use this Skill to identify this anti-pattern and guide the team to refactor tests for real behavior verification, improving test reliability.

Quick Start

Use the testing-anti-patterns skill to review a test file and identify any instances of testing mock behavior or incomplete mocks.

Frequently Asked Questions about testing-anti-patterns

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

FAQPage Schema
How do I detect when tests are asserting on mocks instead of real behavior?

Mock behavior assertions test the mock's existence rather than verifying actual component functionality. This anti-pattern gives false confidence in test coverage. The testing-anti-patterns skill identifies these cases in JavaScript and TypeScript test suites, guiding refactors toward real behavior verification for reliable tests.

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

Test-only methods pollute production classes and violate separation of concerns, creating maintenance debt and hiding design issues. The skill prevents this anti-pattern by enforcing production code purity, ensuring tests interact with actual public APIs rather than backdoor methods.

What's the best way to know when I'm over-mocking dependencies?

Over-mocking breaks test logic by replacing too many dependencies before understanding their actual behavior. Strategic mocking requires understanding dependencies first. This skill guides correct mocking levels with complete data structures, preventing tests that pass but don't validate real interactions.

Can I use this skill to review incomplete or misaligned mocks in my test suite?

Yes. Incomplete mocks with partial data structures or misaligned expectations cause tests to pass spuriously. The skill detects these governance violations across JavaScript and TypeScript tests, guiding mocks toward completeness and alignment with actual component behavior.

How do I fix tests that give false confidence but still pass?

False-confidence tests often assert on mocks, use incomplete stubs, or test implementation details instead of behavior. This skill detects these patterns in unit test suites and enforces governance rules that redirect tests toward real behavior verification, improving reliability.

Does this work with existing test frameworks and mock libraries?

The skill analyzes unit tests in JavaScript and TypeScript test suites to identify anti-patterns regardless of framework. It focuses on governance rules that apply across mock libraries, guiding refactors toward real behavior verification and production code purity.