Transparently create an API cache for testing using MSW. v5.3.0 (stable). Integrates with MSW v2 to snapshot network requests and replay them in tests, reducing reliance on live APIs. Key differentiators: supports snapshot update strategies (none/all/missing), customizable snapshot paths via createSnapshotPath, and callbacks for fetch events. Ships TypeScript types. Requires msw ^2.0.0 as a peer dependency.
npm install msw-snapshotNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up an MSW server with snapshot middleware, storing new snapshots on first run and replaying them on subsequent runs.
Upgrade to msw ^2.0.0 and use msw-snapshot v5.x.
Change import to 'import { snapshot } from 'msw-snapshot'.Use maskURLSearchParams to ignore volatile params, customizing createSnapshotPath accordingly.
Use 'missing' or 'none' for CI; reserve 'all' for local development when intentional.
Change to: import { snapshot } from 'msw-snapshot'.Run: npm install msw@^2.0.0
Use maskURLSearchParams in createSnapshotPath to ignore 't' or other dynamic params.