testing

Guides behavior-driven test writing, factory patterns, and affected-scope test execution.

Updated May 18, 2024
One-click install
npx skills add https://github.com/joshhornby/dotfiles --skill testing-joshhornby
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/joshhornby/dotfiles/tree/main/.claude/skills/testing
Command: npx skills add https://github.com/joshhornby/dotfiles --skill testing-joshhornby

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Tests often verify implementation details instead of behavior, inflate coverage without catching bugs, and run wastefully broad or dangerously narrow scopes. This Skill enforces behavior-driven testing through public interfaces, detects coverage theater, and selects the correct affected test scope for each TDD phase. ## Core Features & Use Cases - Behavior-Over-Implementation Testing: Enforces testing through the subject's public interface at the layer the claim names, with concrete wrong/right TypeScript examples. - Test Factory Pattern: Provides typed factory functions with schema reuse, composition, and override patterns for maintainable fixtures. - Affected-Scope Test Execution: Prescribes runner-specific strategies (Vitest, Jest, pytest, Playwright, Go/Rust/JVM) for RED/GREEN/REFACTOR phases, including watch-mode proof requirements. - Use Case: When writing tests for a payment processing function, the Skill steers you to assert on the whole Result value through processPayment() rather than spying on internal validators, and to run the affected scope rather than the full suite during refactoring. ## Quick Start Ask the assistant to write behavior-driven tests for your function using this testing skill, following its factory and affected-scope execution guidance.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I write behavior-driven tests instead of testing implementation details?

Test through the subject's public interface at the layer your claim names, asserting on outcomes rather than spying on internal collaborators. For example, call processPayment() and assert the whole Result value instead of checking that an internal validator was called.

How do I create test factories with TypeScript?

Write factory functions that accept Partial<T> overrides and return complete, scenario-valid objects, reusing the production schema via parse when one exists. Compose factories for nested objects and use Partial<Pick<T, ...>> to constrain which fields callers can override.

Which tests should I run during TDD with Vitest or Jest?

Use an exact file or name selector only to prove RED or debug. For GREEN/REFACTOR, prefer a proven repository-owned watcher, then runner-derived affected scopes like vitest --changed or jest --changedSince, never hand-picked test files.

What is coverage theater and how do I avoid it?

Coverage theater is executing code without proving behavior, such as mocking the function under test or asserting only that a spy was called. Avoid it by asserting on observable outcomes, covering edge cases and branches, and checking that tests would fail against realistic mutants.

Should every source file have a matching test file?

No. Organize tests around stable behaviors or contracts rather than mirroring implementation files one-to-one. A 1:1 file is acceptable only when that file itself is the public unit under test.

When should I not use this testing skill?

Do not use it for UI-specific testing, which is explicitly out of scope per the skill description. For mutation analysis depth, load the separate mutation-testing skill, and for the RED-GREEN-REFACTOR workflow itself, load the TDD skill.