Back to Explore

mswjs/msw

GitHub
12 updates · last 90 days1 watchersOpen source

Last release:

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: mswjs/msw shows recent upstream activity (last push on 2026-07-08) and a steady stream of updates through July 2026, indicating the project is actively developed rather than dormant.
  • Update cadence: Updates land frequently over the past few months (for example, multiple patch updates in April to May 2026, then several SSE-related updates in early July 2026), with the most recent updates on 2026-07-08 and 2026-07-07.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v2.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.

    Features
  • v2.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.

    Features
  • v2.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.

    Features
  • v2.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.