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 —
setupWorkerfrommsw/browserin development,setupServerfrommsw/nodein 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 development —
setupWorkerfrommsw/browser, awaited before the app renders, with runtime variant switching to walk the UI through its states. Follow examples/browser.md. - Node, in tests —
setupServerfrommsw/node, listening for the suite and reset between tests, withserver.use()for one-test overrides. Follow examples/core.md.