MSW (Mock Service Worker) best practices for API mocking in tests (formerly test-msw). This skill should be used when setting up MSW, writing request handlers, or mocking HTTP APIs. This skill does NOT cover general testing patterns (use test-vitest or test-tdd skills) or test methodology.
Comprehensive API mocking guide for MSW (Mock Service Worker) v2 applications. This skill helps you set up MSW correctly, write effective request handlers, and integrate with test frameworks.
This skill contains 45 rules across 8 categories, organized by impact level:
| Category | Rules | Impact | |----------|-------|--------| | Setup & Initialization | 6 | CRITICAL | | Handler Architecture | 8 | CRITICAL | | Test Integration | 7 | HIGH | | Response Patterns | 6 | HIGH | | Request Matching | 5 | MEDIUM-HIGH | | GraphQL Mocking | 4 | MEDIUM | | Advanced Patterns | 5 | MEDIUM | | Debugging & Performance | 4 | LOW |
mswjs/
├── SKILL.md # Entry point with quick reference
├── AGENTS.md # Compiled comprehensive guide
├── metadata.json # Version, references, metadata
├── README.md # This file
├── references/
│ ├── _sections.md # Category definitions
│ ├── setup-*.md # Setup rules (6)
│ ├── handler-*.md # Handler architecture rules (8)
│ ├── test-*.md # Test integration rules (7)
│ ├── response-*.md # Response pattern rules (6)
│ ├── match-*.md # Request matching rules (5)
│ ├── graphql-*.md # GraphQL mocking rules (4)
│ ├── advanced-*.md # Advanced pattern rules (5)
│ └── debug-*.md # Debugging rules (4)
└── assets/
└── templates/
└── _template.md # Rule template
This skill automatically activates when you're working on:
handlers.ts, mocks/*.ts)# Install dependencies (if contributing)
pnpm install
# Build AGENTS.md from rules
pnpm build
# Validate skill structure
pnpm validate
assets/templates/_template.md as your starting point| Prefix | Category | Impact |
|--------|----------|--------|
| setup- | Setup & Initialization | CRITICAL |
| handler- | Handler Architecture | CRITICAL |
| test- | Test Integration | HIGH |
| response- | Response Patterns | HIGH |
| match- | Request Matching | MEDIUM-HIGH |
| graphql- | GraphQL Mocking | MEDIUM |
| advanced- | Advanced Patterns | MEDIUM |
| debug- | Debugging & Performance | LOW |
Each rule follows this template:
---
title: Rule Title Here
impact: CRITICAL|HIGH|MEDIUM-HIGH|MEDIUM|LOW-MEDIUM|LOW
impactDescription: Quantified impact (e.g., "2-10× improvement")
tags: prefix, technique, related-concepts
---
## Rule Title Here
1-3 sentences explaining WHY this matters.
**Incorrect (what's wrong):**
\`\`\`typescript
// Bad example
\`\`\`
**Correct (what's right):**
\`\`\`typescript
// Good example
\`\`\`
Reference: [Link](https://example.com)
Rule files follow the pattern: {prefix}-{description}.md
Examples:
setup-server-node-entrypoint.md - Setup category, about Node.js entrypointhandler-happy-path-first.md - Handler category, about handler organizationtest-reset-handlers.md - Test category, about resetting handlers| Level | Description | |-------|-------------| | CRITICAL | MSW fails to function without this | | HIGH | Major degradation in test reliability | | MEDIUM-HIGH | Significant impact on specific workflows | | MEDIUM | Noticeable improvement in quality | | LOW-MEDIUM | Incremental improvement | | LOW | Minor optimization |
| Command | Description |
|---------|-------------|
| pnpm build | Compiles rules into AGENTS.md |
| pnpm validate | Validates skill structure and rules |
assets/templates/_template.md)This skill draws from:
Apache 2.0
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer