Mocking Stubbing
Structured guide for isolating unit tests with mocks, stubs, spies, and test doubles across Jest, unittest.mock, and Mockito.
- CCM score
- 37 of 100
- skills.sh installs
- 434
- GitHub stars
- 396
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers creating and managing test doubles to replace databases, APIs, file systems, and other slow or non-deterministic dependencies
- Includes reference guides for Jest, Python
unittest.mock, Mockito for Java, and advanced mocking patterns, plus a TypeScript quick start - Provides a do and don't checklist, such as mocking at the boundary, resetting mocks between tests, and avoiding mocks in integration tests
- Designed for unit test suites where dependency injection makes external services easy to replace with controlled doubles
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill mocking-stubbing -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Mocking and Stubbing
Table of Contents
Overview
Mocking and stubbing are essential techniques for isolating units of code during testing by replacing dependencies with controlled test doubles. This enables fast, reliable, and focused unit tests that don't depend on external systems like databases, APIs, or file systems.
When to Use
- Isolating unit tests from external dependencies
- Testing code that depends on slow operations (DB, network)
- Simulating error conditions and edge cases
- Verifying interactions between objects
- Testing code with non-deterministic behavior (time, randomness)
- Avoiding expensive operations in tests
- Testing error handling without triggering real failures
Quick Start
Minimal working example:
// services/UserService.ts
import { UserRepository } from "./UserRepository";
import { EmailService } from "./EmailService";
export class UserService {
constructor(
private userRepository: UserRepository,
private emailService: EmailService,
) {}
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Categories
- Testing & QA, Backend & APIs
- First seen
- Jun 3, 2026
Questions
What does the mocking-stubbing skill do?
The mocking-stubbing skill creates and manages mocks, stubs, spies, and test doubles to isolate unit tests from external dependencies. It covers Jest mocks, Python unittest.mock, and Mockito for Java, and it teaches replacing slow or non-deterministic dependencies such as databases, network calls, and time with controlled doubles.
Who should use the mocking-stubbing skill?
Developers who write unit tests and need to isolate code from databases, APIs, file systems, or other slow dependencies will find the mocking-stubbing skill useful. It also helps when simulating error conditions or verifying interactions between objects in tests.
How do I install the mocking-stubbing skill?
Run npx -y skills add aj-geddes/useful-ai-prompts --skill mocking-stubbing -y inside your project. Once installed, the mocking-stubbing skill lets your agent write mocks, stubs, and spies for your unit tests.
Where does the mocking-stubbing skill sit in Testing & QA?
The mocking-stubbing skill is listed in the Testing & QA category on Claude Marketplaces, alongside tdd, test-driven-development, and webapp-testing. It stands apart by focusing specifically on test doubles and dependency isolation rather than on the wider test workflow.
More from aj-geddes/useful-ai-prompts
All 258- Server Side Rendering434
- Data Migration Scripts432
- Correlation Tracing430
- Dimensionality Reduction430
- Synthetic Monitoring429
- Canary Deployment428
- Model Monitoring428
- Model Deployment427
- Service Mesh Implementation427
- Data Replication Setup426
- Polyglot Integration426
- Azure Functions425
- Graphql Implementation425
- Multi Cloud Strategy420
- Distributed Tracing419
- Nodejs Express Server3.3K
- Code Review Analysis2.4K
- Jenkins Pipeline2.2K
- Rest Api Design2.1K
- Architecture Diagrams2K
- Ansible Automation1.9K
- Ios Swift Development1.5K
- Nginx Configuration1.5K
- Android Kotlin Development1.5K
Similar to Mocking Stubbing
More Testing & QAunit-testing-frameworkaj-geddes/useful-ai-prompts635 installsStructured guidance for writing unit tests with Jest, pytest, JUnit, or RSpec, following the AAA pattern.
testing-patternsvudovn/ag-kit215 installsReference guide of testing principles covering the test pyramid, AAA structure, and mocking strategies for reliable suites.
integration-testingaj-geddes/useful-ai-prompts564 installsDesign integration tests that verify real API, database, and service interactions without mocking the data layer.
javascript-testing-patternswshobson/agents21.6K installsComprehensive testing guide covering Jest and Vitest setup, unit, async, and mocking patterns for JavaScript and TypeScript.
Testing Anti-Patternsbobmatnyc/claude-mpm-skills390 installsAuthoritative guide for avoiding testing anti-patterns, covering mock misuse, test-only production code, and incomplete mocks.
jestmindrally/skills922 installsJest testing guidance for JavaScript and TypeScript covering structure, mocking, assertions, and async patterns.