/test-doubles-generator:gen-doublesfrom test-doubles-generator
Analyzes code dependencies and generates appropriate test doubles (mocks, stubs, spies, fakes) with implementations, usage examples, and test data fixtures.
Ships in test-doubles-generator. Installing the plugin adds it to Claude Code.
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
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub danielmiessler/claude-code-plugins-plus --plugin test-doubles-generator3 plugins ship this exact command · first indexed Dec 31, 2025
Other plugins' commands for the same job