web-mocks-msw

Installation
SKILL.md

MSW Patterns

Quick Guide: MSW intercepts requests at the network layer, so application code never learns it is mocked. One handler set serves both environments — setupWorker from msw/browser in development, setupServer from msw/node in tests — and the two are not interchangeable. Keep response bodies in their own module so each variant (default, empty, error) is reusable and typed against your API's generated types.

Detailed Resources:

  • examples/core.md — mock data modules, variant handlers, server setup and test lifecycle, per-test overrides, runtime variant switching, simulated latency
  • examples/browser.md — browser worker setup and app integration for client-rendered and server-rendered entry points

Which path applies

Handlers are shared; only the setup module and the lifecycle differ.

  • Browser, during developmentsetupWorker from msw/browser, awaited before the app renders, with runtime variant switching to walk the UI through its states. Follow examples/browser.md.
  • Node, in testssetupServer from msw/node, listening for the suite and reset between tests, with server.use() for one-test overrides. Follow examples/core.md.

Installs
58
GitHub Stars
24
First Seen
Apr 7, 2026
web-mocks-msw — agents-inc/skills