Generates test doubles (mocks, stubs, spies, fakes) for unit testing by analyzing dependencies and producing implementations with test cases and fixtures.
How this command is triggered — by the user, by Claude, or both
Slash command
/test-doubles-generator:gen-doublesThe summary Claude sees in its command listing — used to decide when to auto-load this command
# Test Doubles Generator Generate appropriate test doubles (mocks, stubs, spies, fakes, dummies) for unit testing based on the testing framework and dependencies being tested. ## What You Do 1. **Analyze Dependencies** - Identify external dependencies in code under test - Determine appropriate test double type for each - Generate test doubles with proper behavior 2. **Generate Mocks** - Create mock implementations with verification - Set up method expectations and return values - Configure mock behavior for test scenarios 3. **Generate Stubs** - Create stub impleme...
Generate appropriate test doubles (mocks, stubs, spies, fakes, dummies) for unit testing based on the testing framework and dependencies being tested.
Analyze Dependencies
Generate Mocks
Generate Stubs
Generate Spies
When invoked, you should:
## Test Doubles Generated for: [Component]
### Dependencies Identified: [N]
#### Dependency: [Name]
**Type:** [API / Database / Service / File System]
**Test Double:** [Mock / Stub / Spy / Fake]
**Rationale:** [Why this type]
**Implementation:**
\`\`\`javascript
// Mock for [Name]
const mock[Name] = {
methodName: jest.fn()
.mockResolvedValueOnce([success response])
.mockRejectedValueOnce(new Error('[error]')),
anotherMethod: jest.fn().mockReturnValue([value])
};
\`\`\`
**Usage in Tests:**
\`\`\`javascript
describe('[Component]', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('should [behavior]', async () => {
// Arrange
mock[Name].methodName.mockResolvedValue([data]);
// Act
const result = await componentUnderTest.action();
// Assert
expect(mock[Name].methodName).toHaveBeenCalledWith([expected args]);
expect(result).toEqual([expected result]);
});
it('should handle errors', async () => {
// Arrange
mock[Name].methodName.mockRejectedValue(new Error('[error]'));
// Act & Assert
await expect(componentUnderTest.action()).rejects.toThrow('[error]');
});
});
\`\`\`
### Test Data Fixtures
\`\`\`javascript
const fixtures = {
validData: { /* ... */ },
invalidData: { /* ... */ },
edgeCases: { /* ... */ }
};
\`\`\`
### Next Steps
- [ ] Implement generated test doubles
- [ ] Write test cases using doubles
- [ ] Verify test coverage
- [ ] Refactor for reusability
Mock: Behavior verification, tracks calls and arguments Stub: State verification, returns predefined responses Spy: Wraps real object, tracks interactions Fake: Working implementation with shortcuts (in-memory DB) Dummy: Placeholder objects, not used in test
npx claudepluginhub danielmiessler/claude-code-plugins-plus --plugin test-doubles-generator24plugins reuse this command
First indexed Dec 31, 2025
Showing the 6 earliest of 24 plugins
/gen-doublesGenerates test doubles (mocks, stubs, spies, fakes) for unit testing by analyzing dependencies and producing implementations with test cases and fixtures.
/mock-genGenerates type-safe mocks and stubs for a given module or interface, with call tracking, default zero values, a factory function, and an example test.
/generate-testsGenerates comprehensive unit tests for source code files, covering happy paths, edge cases, error handling, mocking, and assertions. Auto-detects test framework (Jest, pytest, JUnit, etc.) and produces structured test files.
/generate-test-casesAnalyzes target code and generates comprehensive unit, integration, and edge-case test suites with mocks, stubs, and data-driven tests.
/generate-testsGenerates a comprehensive test suite for the specified code, including unit, integration, and framework-specific tests following project conventions.