mocks

Guide test double selection to isolate code under test from dependencies.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/js-rom/Luis --skill mocks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mocks
Source: https://github.com/js-rom/Luis/tree/main/.agents/skills/mocks
Command: npx skills add https://github.com/js-rom/Luis --skill mocks

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Test doubles help isolate the code under test (SUT) from dependencies, speeding up unit tests and improving reliability by avoiding flaky external systems.

Core Features & Use Cases

  • Stub returns predefined outputs for given inputs and is ideal for state-based tests.
  • Mock defines interaction expectations (arguments, call counts, and sequence) and verifies them.
  • Spy combines stub behavior with interaction verification.
  • Dummy fills argument lists without participating in behavior.
  • Fake provides a lightweight in-memory implementation for simple scenarios.
  • Use Case: When testing a service that calls a repository, replace the repository with a stub or mock to verify behavior without touching the database.

Quick Start

Identify the DOCs involved, choose appropriate double types, and inject them into your unit tests to isolate the SUT.

Frequently Asked Questions about mocks

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

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

A stub returns predefined outputs for given inputs to support state-based tests, while a mock defines interaction expectations like arguments, call counts, and sequence to verify behavior during unit isolation.

How do I isolate the system under test from slow or nondeterministic dependencies?

To isolate the SUT from slow or nondeterministic dependencies, identify the dependent components, select appropriate test doubles like stubs or mocks, and inject them to ensure fast, deterministic tests.

When should I use a spy versus a fake test double?

Use a spy to combine stub behavior with interaction verification, and use a fake when you need a lightweight in-memory implementation for simple testing scenarios.

What's the best way to verify repository interactions without touching the database?

The best way to verify repository interactions without touching the database is replacing the repository with a mock or stub test double to verify service behavior quickly and deterministically.

Why do my unit tests with test doubles still fail intermittently?

Unit tests using test doubles can fail intermittently if double contracts and interaction expectations are loosely defined, causing fragility when call sequences or argument mismatches occur during verification.