- Home
- Skills
- Protagonistss
- Ithinku Plugins
- Mock Generation
mock-generation_skill
- TypeScript
0
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill protagonistss/ithinku-plugins --skill mock-generation- SKILL.md9.6 KB
Overview
This skill generates mock data and stub functions for tests to isolate external dependencies and speed up development. It creates typed mock objects, realistic datasets, API responses, database stubs, and time/random controls. The skill supports Jest and Vitest templates and offers configurable generation options for edge cases and error scenarios. It is focused on TypeScript projects and produces reusable, test-friendly mocks.
How this skill works
The skill analyzes module exports, function signatures, return types, and common external interactions (DB, HTTP, timers, randomness) to determine what to mock. It generates typed mock objects, factory-based data generators, API response shapes, and stub implementations with sync/async behaviors. Templates for Jest, Vitest, and Python show how to wire mocks into test suites, and utilities provide boundary, invalid, and paginated responses. Call-history, custom return values, and error simulation are supported for detailed behavior control.
When to use it
- When tests rely on external APIs, databases, or system time and need isolation.
- When generating realistic but deterministic datasets for unit or integration tests.
- When you need reusable factories for complex nested objects or lists.
- When testing error handling: network, timeout, validation, or database edge cases.
- When you want consistent mock templates for Jest, Vitest, or cross-language examples.
Best practices
- Only mock external dependencies; keep business logic unmocked to avoid false confidence.
- Use factory/generator patterns to produce reusable, consistent test data.
- Include boundary and invalid-data generators to validate error paths.
- Reset or clear mocks between tests (beforeEach/afterEach) to avoid cross-test leakage.
- Prefer partial mocks over full module replacements when you want to preserve real behavior selectively.
Example use cases
- Auto-generate mocks for a user service module with typed return values and spies for Vitest.
- Create stubbed database methods (findById, create, update) that return realistic user fixtures, including not-found cases.
- Mock fetch/XHR to return paginated API responses, success, and error scenarios for frontend tests.
- Produce time-controlled tests using fake timers for delayed callbacks and scheduled jobs.
- Generate sequences of async stub behaviors to test retry and promise-chain logic.
FAQ
Yes. It supports async stubs, mockResolvedValue/mockRejectedValue sequences and configurable multi-call behaviors.
How do I control generated values or provide custom returns?
You can pass customReturnValues per export or provide override objects to generators to shape returned fixtures.