Mock Service Worker (MSW) is an API mocking library for JavaScript that intercepts requests and returns mock responses. It helps developers test and develop against consistent network behavior without stubbing application code, with support for both browser (via Service Worker) and Node.js (via request interception).
Project status
- Actively maintained: The repo shows very recent activity, with updates on 2026-10-10, and multiple follow-up updates in late September and early October, indicating the project is actively maintained rather than dormant.
- Update cadence: The most recent series suggests a fast patch cadence, with v3.0.3 (2026-10-10), v3.0.2 (2026-10-03), v3.0.1 (2026-09-30), and v3.0.0 (2026-09-28), all within about two weeks.
AI summary generated
Recent updates
v3.0.4
v3.0.4 fixes worker behavior when the browser terminates and later restarts the service worker, and recognizes `.ico` requests as common assets. The code also changes the TypeScript nightly CI workflow; no public API or dependency changes are evident.
v3.0.3
v3.0.3 is a patch release focused on handler lifecycle behavior during `resetHandlers()` and on exposing the resolved network context to network sources when they are enabled. The code changes also touch how browser “quiet” logging is controlled, and they adjust GraphQL subscription handling during resets. A number of tests were added or updated to cover these scenarios.
v3.0.2
v3.0.2 primarily addresses a Vitest compatibility issue for Mock Service Worker (MSW), specifically enabling `virtual:msw` imports. The code changes also refactor how the MSW network is constructed for the Vite plugin runtime, removing an older virtual module used for network options.
v3.0.1
v3.0.1 focuses on fixing how MSW handles HTTP CONNECT requests by treating them as proxy transport rather than as matchable HTTP requests. The change adds regression tests for CONNECT tunneling behavior in Node and updates internal HTTP frame and handler logic accordingly.
v3.0.0
MSW v3.0.0 is a major release that modernizes the package for ESM-only usage and raises minimum platform requirements (Node.js 22+, TypeScript 5.9+). It introduces a new network configuration approach centered around `defineNetwork`, updates GraphQL and WebSocket integration points, and changes request and lifecycle behaviors to better align with runtime semantics.
BreakingFeaturesv2.15.0
v2.15.0 adds SSE-specific support for running `finalize` callbacks when the SSE response stream ends. The implementation goes beyond SSE, updating the general `finalize` cleanup scheduling behavior for streamed (ReadableStream) responses and changing how SSE response bodies are cloned/observed.
Featuresv2.14.7
v2.14.7 is a small release that (per the notes) fixes SSE logging behavior under concurrent requests. The code diff confirms a real change in the SSE handler to scope logging per request/connection to prevent duplicated or leaking log listeners across concurrent streams.
v2.14.6
v2.14.6 includes a fix in `defineNetwork` to prevent previously-attached frame event listeners from forwarding events across enable/disable cycles. The release notes describe the intent, but the code introduces additional behavioral changes in how listeners are cleaned up and how dispose-time errors are handled.
v2.14.5
v2.14.5 is a small bug fix release focused on WebSocket behavior during client shutdown. It adds cleanup logic so frame-related event listeners are removed when the client WebSocket connection closes.
v2.14.4
v2.14.4 introduces a new `finalize` callback API for request handlers, intended to let developers schedule cleanup logic that runs after the handler finishes. The change is implemented in the core `RequestHandler` execution flow and is covered by new Node-focused tests and updated TypeScript typing tests.
Featuresv2.14.3
v2.14.3 primarily addresses a memory leak related to per-request frame abort listener cleanup. The implementation now aggressively removes event emitter listeners from frames after emitting the response, and adds a dedicated heap snapshot based memory test suite.
v2.14.2
v2.14.2 makes a small change related to public type exports in the experimental core API. The release notes describe exporting the `NetworkApi` type, and the code diff shows that new type is re-exported from `src/core/experimental/index.ts`.
v2.14.1
v2.14.1 is a small maintenance release that adds new public exports for handler controller classes. The change appears limited to the library's index files, plus a version bump in package.json.
v2.14.0
v2.14.0 adds support for handling WebSocket connection upgrades via a new `ws.onUpgrade` implementation, including an HTTP Upgrade flow that returns a 101 response with the correct `Sec-WebSocket-Accept` value. It also fixes cookie forwarding behavior and avoids cloning user-provided responses when producing the final mocked response.
Featuresv2.13.6
v2.13.6 mainly introduces a new public `WebSocketHandler.test()` method and extends internal URL matching utilities. The release notes only mention the new `test()` method, but the actual diff also changes the TypeScript signatures of other public methods on `WebSocketHandler`.
v2.13.5
v2.13.5 primarily addresses handler reset behavior for generator-based response resolvers. The code changes implement a more comprehensive handler state reset and restore mechanism (not just toggling an isUsed flag), and they add new internal tests to verify generator state cleanup.
v2.13.4
v2.13.4 is a bug fix release focused on stabilizing ServiceWorker-based mocking and improving Server-Sent Events (SSE) cancellation behavior. It introduces a proper singleton pattern for ServiceWorkerSource and refactors SSE handling to respect request.signal, while also cleaning up exports to be consistent with verbatimModuleSyntax.