mock-service

Create TypeScript-safe mock services with MSW, Nock, or custom servers.

13|3|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/heaptracetechnology/heaptrace-skills --skill mock-service-heaptracetechnology
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mock-service
Source: https://github.com/heaptracetechnology/heaptrace-skills/tree/main/automation-qa/mock-service
Command: npx skills add https://github.com/heaptracetechnology/heaptrace-skills --skill mock-service-heaptracetechnology

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Create mock APIs and services for testing using MSW, Nock, or custom mock servers. Covers when to mock vs use real services, mock data factories, network request interception, test reset patterns, and TypeScript-safe mocking. Produces reliable, maintainable test doubles.

Core Features & Use Cases

  • MSW (Mock Service Worker) for browser and integration tests
  • Nock for Node.js tests and API clients
  • Custom mock servers for end-to-end testing
  • Factory patterns for test data generation
  • TypeScript-safe mocks with contract-oriented practices

Quick Start

Use MSW or Nock in your test suite to create mock services that intercept HTTP requests, then rely on factories and reset patterns to keep mocks in sync.

Frequently Asked Questions about mock-service

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

FAQPage Schema
How do I mock APIs for frontend and backend tests?

MSW intercepts HTTP requests at the network level to mock APIs for browser and integration tests, while Nock intercepts requests for Node.js tests and API clients. Both produce deterministic test doubles by returning contract-accurate responses.

What's the best way to generate test data for mock services?

The best way to generate test data for mock services is using factory patterns. Test data factories create consistent, contract-accurate responses and integrate with reset patterns to keep mocks in sync across test runs.

Does MSW work with TypeScript for contract testing?

Yes, MSW works with TypeScript for contract testing by providing properly typed mock services. TypeScript-safe mocks enforce contract-oriented practices, ensuring stateful mocks and error handling match real API dependencies.

When should I mock APIs instead of using real services in tests?

You should mock APIs instead of using real services when you need deterministic test behavior, contract-accurate responses, or want to simulate error handling and stateful responses without external network dependencies or live data risks.

How do I reset mock state between test runs?

To reset mock state between test runs, apply test reset patterns alongside your data factories. These patterns clear network request interceptions and restore custom mock servers to their initial state for deterministic behavior.