Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
pproenca avatar

Msw

  • 578 installs
  • 186 repo stars
  • Updated July 24, 2026
  • pproenca/dot-skills

msw is a Claude Code skill that generates and maintains Mock Service Worker v2 setups, handlers, and debugging patterns so developers eliminate flaky API tests and unhandled request errors.

About

msw is a pproenca dot-skills guide at version 1.0.0 for mswjs Mock Service Worker v2, packing 45+ rules across 8 categories from critical setup and handler architecture through incremental debugging guidance. Each rule pairs incorrect versus correct examples with impact notes so agents scaffold browser and Node interceptors, REST and GraphQL handlers, and error paths consistently. Developers reach for msw when standing up API mocks for React or Vitest suites, refactoring legacy MSW v1 handlers, or stopping unhandled-request failures during CI component tests.

  • 45+ prioritized rules across 8 categories
  • Critical setup guidance including committing the worker script and configuring lifecycle hooks
  • Real-world incorrect vs correct code examples with impact metrics
  • TypeScript v2 configuration and unhandled request behavior rules
  • Designed specifically for AI agents and automated refactoring workflows

Msw by the numbers

  • 578 all-time installs (skills.sh)
  • Ranked #598 of 2,159 Testing & QA skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Jul 31, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pproenca/dot-skills --skill msw

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs578
repo stars186
Security audit3 / 3 scanners passed
Last updatedJuly 24, 2026
Repositorypproenca/dot-skills

How do you set up MSW v2 handlers for API tests?

Generate consistent, production-grade Mock Service Worker setups and handlers that eliminate flaky tests and unhandled request errors.

Who is it for?

Frontend and full-stack developers standardizing Mock Service Worker v2 across Vitest, Playwright, or Storybook test suites.

Skip if: Backend-only integration tests hitting real databases, projects already on MSW v1 without a migration plan, or teams mocking exclusively with static JSON fixtures.

When should I use this skill?

A developer asks to mock APIs with MSW, fix unhandled request errors, or generate handlers for frontend tests.

What you get

MSW v2 worker/bootstrap files, typed HTTP handlers, and test configurations without unhandled-request or flaky mock errors.

  • MSW worker setup files
  • HTTP handler modules
  • Test-ready mock configurations

By the numbers

  • Contains 45+ rules across 8 categories
  • Skill version 1.0.0 for MSW v2 (mswjs), January 2026

Files

SKILL.mdMarkdownGitHub ↗

MSW Best Practices

Comprehensive API mocking guide for MSW v2 applications, designed for AI agents and LLMs. Contains 45 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Setting up MSW for testing or development
  • Writing or organizing request handlers
  • Configuring test environments with MSW
  • Mocking REST or GraphQL APIs
  • Debugging handler matching issues
  • Testing error states and edge cases

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Setup & InitializationCRITICALsetup-
2Handler ArchitectureCRITICALhandler-
3Test IntegrationHIGHtest-
4Response PatternsHIGHresponse-
5Request MatchingMEDIUM-HIGHmatch-
6GraphQL MockingMEDIUMgraphql-
7Advanced PatternsMEDIUMadvanced-
8Debugging & PerformanceLOWdebug-

Quick Reference

1. Setup & Initialization (CRITICAL)

  • setup-server-node-entrypoint - Use correct entrypoint for Node.js (msw/node)
  • setup-lifecycle-hooks - Configure server lifecycle in test setup
  • setup-worker-script-commit - Commit worker script to version control
  • setup-node-version - Require Node.js 18+ for MSW v2
  • setup-unhandled-requests - Configure unhandled request behavior
  • setup-typescript-config - Configure TypeScript for MSW v2

2. Handler Architecture (CRITICAL)

  • handler-happy-path-first - Define happy path handlers as baseline
  • handler-domain-grouping - Group handlers by domain
  • handler-absolute-urls - Use absolute URLs in handlers
  • handler-shared-resolvers - Extract shared response logic into resolvers
  • handler-v2-response-syntax - Use MSW v2 response syntax
  • handler-request-body-parsing - Explicitly parse request bodies
  • handler-resolver-argument - Destructure resolver arguments correctly
  • handler-reusability-environments - Share handlers across environments

3. Test Integration (HIGH)

  • test-reset-handlers - Reset handlers after each test
  • test-avoid-request-assertions - Avoid direct request assertions
  • test-concurrent-boundary - Use server.boundary() for concurrent tests
  • test-fake-timers-config - Configure fake timers to preserve queueMicrotask
  • test-async-utilities - Use async testing utilities for mock responses
  • test-clear-request-cache - Clear request library caches between tests
  • test-jsdom-environment - Use correct JSDOM environment for Jest

4. Response Patterns (HIGH)

  • response-http-response-helpers - Use HttpResponse static methods
  • response-delay-realistic - Add realistic response delays
  • response-error-simulation - Simulate error responses correctly
  • response-one-time-handlers - Use one-time handlers for sequential scenarios
  • response-custom-headers - Set response headers correctly
  • response-streaming - Mock streaming responses with ReadableStream

5. Request Matching (MEDIUM-HIGH)

  • match-url-patterns - Use URL path parameters correctly
  • match-query-params - Access query parameters from request URL
  • match-custom-predicate - Use custom predicates for complex matching
  • match-http-methods - Match HTTP methods explicitly
  • match-handler-order - Order handlers from specific to general

6. GraphQL Mocking (MEDIUM)

  • graphql-operation-handlers - Use operation name for GraphQL matching
  • graphql-error-responses - Return GraphQL errors in correct format
  • graphql-batched-queries - Handle batched GraphQL queries
  • graphql-variables-access - Access GraphQL variables correctly

7. Advanced Patterns (MEDIUM)

  • advanced-bypass-requests - Use bypass() for passthrough requests
  • advanced-cookies-auth - Handle cookies and authentication
  • advanced-dynamic-scenarios - Implement dynamic mock scenarios
  • advanced-vitest-browser - Configure MSW for Vitest browser mode
  • advanced-file-uploads - Mock file upload endpoints

8. Debugging & Performance (LOW)

  • debug-lifecycle-events - Use lifecycle events for debugging
  • debug-verify-interception - Verify request interception is working
  • debug-common-issues - Know common MSW issues and fixes
  • debug-request-logging - Log request details for debugging

How to Use

Read individual reference files for detailed explanations and code examples:

  • Section definitions - Category structure and impact levels
  • Rule template - Template for adding new rules
  • Individual rules: references/{prefix}-{slug}.md

Related Skills

  • For generating MSW mocks from OpenAPI, see orval skill
  • For consuming mocked APIs, see tanstack-query skill
  • For test methodology, see test-vitest or test-tdd skills

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Related skills

How it compares

Choose msw over ad-hoc fetch stubs when you need shared browser and Node interceptors with explicit handler architecture rules.

FAQ

Which MSW version does the msw skill target?

The msw skill targets Mock Service Worker v2 from mswjs and is labeled version 1.0.0, with rules written for current handler APIs rather than legacy v1 patterns.

How many guidelines does the msw skill include?

The msw skill bundles 45+ rules organized into 8 categories, ranked from critical setup and handler architecture down to incremental debugging practices.

Is Msw safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Testing & QAintegrationstesting

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.