Generate mocks, stubs, spies, and fakes for dependency isolation.
SkillScore91Maintained
Automatic
◆QA & Test Engineering packtestingtest-doubles
Last verified 8/30/2026
What it changes
Passed 19 of 21 test cases with the skill, and 17 of 21 without it.
Without skill82%
With skill91%
Checks it passed that the model alone missed
Recommends using a mock to verify call counts, arguments, and invocation side effects
Recommends invoking `jest.restoreAllMocks()` or `jest.clearAllMocks()` in teardown hooks
Provides a summary listing each generated double, its assigned double type, and the interface it replaces
3 fixed17 passed either way1 still failing1 broke
Pass-rate lift
+9 pp
Tokens
+69%
Agent turns
0%
Response time
-11%
Model gemini-3.6-flashMeasured 8/30/2026v120 of 22 cases passed with skill · 21 comparable
Tokens, turns and time describe resource use, not a dollar price.
See it in action
One of 3 test cases the skill fixed. Same model, same prompt, with and without the skill.
1 of 3
Prompt
Our Jest test suites pass when run individually but fail when executed together due to mock histories and return values persisting across test cases. What cleanup call should be added to teardown hooks?
What was checked, without and with the skill
Checked
Without skill
With skill
Recommends invoking `jest.restoreAllMocks()` or `jest.clearAllMocks()` in teardown hooks
Missed
Passed
case-09 · gemini-3.6-flash · 8/30/2026 · answers are capped and redacted
What's inside
The instructions your model reads when the skill loads.
SKILL.md96 lines6 filesincludes scripts
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
Scan the codebase with Glob and Grep to identify modules with external dependencies (database clients, HTTP clients, file system access, third-party SDKs).
Read each module under test and catalog its dependency interfaces -- list every method signature, return type, and side effect.
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).
Generate test double files following the project's existing test directory structure (e.g., __mocks__/, test/doubles/, testutil/).
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.
Wire test doubles into existing test files using the framework's dependency injection pattern (jest.mock(), @patch, constructor injection, or Go interface substitution).
Validate all test doubles compile and pass type checks by running tsc --noEmit or equivalent.
Output
Test double source files (one per dependency) placed in the project's mock directory
Factory functions with TypeScript generics or equivalent type safety
Jest __mocks__ auto-mock modules where applicable
Updated test files wired to use generated doubles instead of real dependencies
Summary listing each double, its type (mock/stub/spy/fake), and the interface it replaces