Agent skill · software engineering · jeremylongshore
generating-test-doubles
Generate mocks, stubs, spies, and fakes for dependency isolation.
Why this skill is useful
Generates specific test double implementations for various testing frameworks that the AI wouldn't reliably create on its own.
What it needs
Requires jest, mockito, pytest, sinon installed locally. About 3k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.
What this skill does
Test Doubles Generator Overview Generate mocks, stubs, spies, and fakes to isolate units under test from external dependencies. Supports Jest mocks, Sinon.js stubs, Python unittest.mock, Go interfaces, and testdouble.js patterns. Prerequisites Testing framework installed (Jest, Vitest, Mocha, pytest, JUnit 5, or Go testing) Mocking library available (Sinon.js, testdouble.js, unittest.mock, Mockito, or gomock) TypeScript strict mode enabled for type-safe mocks (if applicable) Source code with clear interface or class boundaries for dependency injection Instructions 1. Scan the codebase with Glob and Grep to identify modules with external dependencies (database clients, HTTP clients, file system access, third-party SDKs). 2. Read each module under test and catalog its dependency interfaces -- list every method signature, return type, and side effect. 3. Determine the appropriate test double type for each dependency: Stub: Returns canned data, no behavior verification (use for database queries returning fixed datasets). Mock: Verifies interactions -- call count, argument matching, call order (use for email senders, event emitters). Spy: Wraps real implementation while recording calls (use when partial behavior is needed). Fake: Lightweight working implementation (use for in-memory repositories replacing real databases). 4. Generate test double files following the project's existing test directory structure (e.g., mocks/, test/doubles/, testutil/). 5. For each test double, implement: Factory function or class matching the dependency interface exactly. Configurable return values via builder pattern or method chaining. Call recording for assertion (arguments, call count, call order). Reset/restore mechanism for cleanup between tests. 6. Wire test doubles into existing test files using the framework's dependency injection pattern (jest.mock(), @patch, constructor injection, or Go interface substitution). 7. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/generating-test-doubles--b99fdf