Claude-code-plugins-plus generating-test-doubles
install
source · Clone the upstream repo
git clone https://github.com/jeremylongshore/claude-code-plugins-plus-skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/jeremylongshore/claude-code-plugins-plus-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/backups/skill-structure-cleanup-20251108-073936/plugins/testing/test-doubles-generator/skills/test-doubles-generator" ~/.claude/skills/jeremylongshore-claude-code-plugins-plus-generating-test-doubles-27a9f6 && rm -rf "$T"
manifest:
backups/skill-structure-cleanup-20251108-073936/plugins/testing/test-doubles-generator/skills/test-doubles-generator/SKILL.mdsource content
Overview
This skill empowers Claude to streamline unit testing by automatically generating test doubles (mocks, stubs, spies, and fakes). It analyzes the code under test, identifies dependencies, and creates the necessary test doubles, significantly reducing the time and effort required to write effective unit tests.
How It Works
- Dependency Analysis: Claude analyzes the code to identify dependencies that need to be replaced with test doubles.
- Test Double Generation: Based on the dependencies and specified testing framework, Claude generates appropriate test doubles (mocks, stubs, spies, or fakes).
- Code Insertion: Claude provides the generated test double code, ready for integration into your unit tests.
When to Use This Skill
This skill activates when you need to:
- Create mocks for external API calls in a unit test.
- Generate stubs for service dependencies to control their behavior.
- Implement spies to track interactions with real objects during testing.
Examples
Example 1: Generating Mocks for API Calls
User request: "Generate mocks for the
fetchData function in dataService.js using Jest."
The skill will:
- Analyze the
file to identify thedataService.js
function and its dependencies.fetchData - Generate a Jest mock for
, allowing you to simulate API responses.fetchData
Example 2: Creating Stubs for Service Dependencies
User request: "Create stubs for the
NotificationService in userService.js using Sinon."
The skill will:
- Analyze
and identify theuserService.js
dependency.NotificationService - Generate a Sinon stub for
, enabling you to control its behavior during testing ofNotificationService
.userService.js
Best Practices
- Framework Selection: Specify the testing framework you are using (e.g., Jest, Sinon) for optimal test double generation.
- Code Context: Provide the relevant code snippets or file paths to ensure accurate dependency analysis.
- Test Double Type: Consider the purpose of the test double. Use mocks for behavior verification, stubs for controlled responses, and spies for interaction tracking.
Integration
This skill integrates directly with your codebase by providing generated test double code snippets that can be easily copied and pasted into your unit tests. It supports popular testing frameworks and enhances the overall testing workflow.