test-doubles

Classify test doubles and apply Testcontainers for real middleware integration testing.

Updated Jun 24, 2026
One-click install
npx skills add https://github.com/Hakkadaikon/hymme --skill test-doubles-hakkadaikon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-doubles
Source: https://github.com/Hakkadaikon/hymme/tree/main/skills/test-doubles
Command: npx skills add https://github.com/Hakkadaikon/hymme --skill test-doubles-hakkadaikon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Confusing stubs with mocks leads to over-specified, brittle tests, and mocking managed dependencies like your own database hides real SQL and transaction bugs. This Skill clarifies the five test double roles (dummy, stub, mock, spy, fake) and shows when to verify real middleware with Testcontainers instead of mocks. ## Core Features & Use Cases - Five-type classification: Distinguishes dummies, stubs, mocks, spies, and fakes by role, enforcing the rule that stubs supply input without verification while mocks verify outgoing calls. - Dependency-based assignment: Maps each collaborator to a double by dependency type (unmanaged out-of-process, managed out-of-process, in-process) with step-by-step procedures and completion checklists. - Testcontainers guidance: Shows how to run real databases like PostgreSQL in disposable containers for integration tests, with vitest TypeScript examples and lifecycle management. - Use Case: When writing a test for a pricing service that calls an exchange-rate API and an audit log, assign a stub for the rate input, a mock for the audit output, and verify each with the correct assertion style. ## Quick Start Ask the AI to review your test file and classify each test double as dummy, stub, mock, spy, or fake, flagging any stub that has call verification attached.

Frequently Asked Questions about test-doubles

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

FAQPage Schema
What is the difference between a stub and a mock?

A stub supplies input to the system under test by returning prepared values and is never verified. A mock verifies outgoing calls to external collaborators using assertions like toHaveBeenCalledWith. Combining both roles in one double signals oversized responsibilities.

How do I choose between a fake and Testcontainers for database tests?

Use a fake like an in-memory repository for fast tests where contract fidelity is not critical. Use Testcontainers with the real database engine when SQL dialects, transaction isolation, or constraints matter, since fakes can diverge from production behavior.

When should I use Testcontainers instead of mocks?

Use Testcontainers for managed out-of-process dependencies like your own PostgreSQL database, where mocking would couple tests to repository implementation details. Reserve it for a small set of integration tests since container startup is much slower than unit tests.

Why are my tests brittle when I verify stub calls?

Verifying stubs with toHaveBeenCalled creates over-specification, locking tests to input-supply details that should be free to change. Only verify mocks that represent outputs to unmanaged external systems, and check stub-supplied values through observable results instead.

Does Testcontainers work with vitest in TypeScript?

Yes, the @testcontainers/postgresql package integrates with vitest using beforeAll to start the container and afterAll to stop it. Give startup a generous timeout such as 60 seconds and keep test data isolated between cases.