mock-generation

Generate mock data and stub functions for TypeScript/JavaScript tests.

Updated Nov 25, 2025
One-click install
npx skills add https://github.com/Protagonistss/ithinku-plugins --skill mock-generation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mock-generation
Source: https://github.com/Protagonistss/ithinku-plugins/tree/main/plugins/test-generator/skills/mock-generation
Command: npx skills add https://github.com/Protagonistss/ithinku-plugins --skill mock-generation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

生成测试所需的Mock数据与Stub函数,帮助隔离测试环境并提高测试效率。

Core Features & Use Cases

  • 依赖分析:自动识别需要Mock的外部依赖,分析函数签名和返回值类型,检测数据库操作、API调用等外部交互,识别时间和随机等不可控因素。
  • Mock数据生成:生成符合类型定义的Mock对象,创建真实的测试数据集,支持复杂嵌套对象的生成,生成边界值和异常数据。
  • Stub函数创建:创建可控的函数替代品,支持多种返回值模式,记录调用历史和参数,模拟异步操作。

Quick Start

运行 mock 生成工作流,为你的模块自动生成 Mock 数据和 Stub 函数,以提升测试可重复性和可维护性。

Frequently Asked Questions about mock-generation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate mock data and stub functions for TypeScript unit tests?

Mock data generation for TypeScript unit tests analyzes function signatures and return types to automatically produce typed mock objects, nested structures, and controllable stub function replacements for deterministic testing.

Can I use this to create mocks for Vitest and Jest integration tests?

Yes, you can create mocks for Vitest and Jest integration tests, as the Skill supports framework-agnostic mocking with specific customizations for these environments, including configurable return values and async operation simulation.

What is the best way to mock API calls and database operations in JavaScript tests?

The best way to mock API calls and database operations in JavaScript tests is using automated dependency detection, which isolates external interactions by generating configurable stub functions that record call history and simulate error scenarios.

Does this mock generation tool support Python unittest frameworks?

Yes, the mock generation tool supports Python unittest frameworks, offering framework-agnostic mocks alongside TypeScript and JavaScript support to isolate backend services and API clients for reliable testing.

How do I simulate error scenarios and edge cases with mock data?

You simulate error scenarios and edge cases with mock data by configuring the generated stub functions to return specific boundary values, exception data, and asynchronous errors during your unit and integration tests.