Mock Service Worker released version 3.0 on Thursday which introduces socket-level interception and an ESM-only build.
The JavaScript API mocking library now intercepts network traffic at the TCP and TLS layers in Node.js. This change allows the tool to capture outgoing requests regardless of the client library used.
Developers must use Node.js 22 or later to use these new features.
New Architecture Supports Sockets and GraphQL
The new architecture moves interception to the JavaScript bindings for Node’s C-level network code. This enables the library to support arbitrary socket-based protocols.
According to InfoQ, SMTP cited as an early example of a supported protocol.
The release also adds GraphQL subscription support to fulfill a long-standing community request. These handlers attach to a graphql.link() and allow users to publish events on demand, LavX News reported.
The update replaces the single msw import with granular entrypoints for HTTP, GraphQL, SSE, and WebSocket. An experimental defineNetwork API was also introduced to eventually replace setupServer and setupWorker.

ESM Migration Changes Runtime Requirements
The library is now distributed exclusively as ECMAScript Modules (ESM). This departs from the older CommonJS system.
Support for Node.js v18 and v20 has been dropped. The library now requires v22, v24, or v26 instead. Projects must also use TypeScript 5.9 or later, Wisevoter noted.
Socket-level interception has caused some immediate friction for users. Notifire reported that some developers are seeing failing tests.
The new version intercepts browser-issued OPTIONS preflight requests that previous versions ignored.
Library Size Drops as Dependencies Shrink
The update reduces the library footprint by removing several transitive dependencies. These include path-to-regexp, picocolors, and statuses.
The graphql dependency is now an optional peer dependency.
| Metric | Version 2.x | Version 3.0 |
|---|---|---|
| Library tarball | 416KB | 234KB |
| Type definitions | 190KB | 90KB |
Interception Reaches Deep Network Layers
Moving to the TCP and TLS wraps represents the limit of how deep the library can integrate with the runtime. This occurs without fundamental changes to the environment.
“Moving any lower would require recompiling Node.js itself,” said the team in a report via InfoQ.
MSW competes with tools like Nock, fetch-mock, and undici’s MockAgent in the Node.js space. But LavX News observed that none of those alternatives cover both the browser and the server using a single handler definition.
Community Feedback Meets New Development
Artem Zakharchenko maintains the library, which is released under the MIT license. It mocks network traffic using runtime-level interception in Node.js and Service Workers in the browser.
In a GitHub discussion numbered 2771, a developer argued against the decision to deprioritize JSDOM and Jest. This developer claimed that a runner with 46 million weekly downloads should receive a formal note regarding breaking changes instead of just a change to the documentation.
Teams using version 2 should consult the official 2.x to 3.x migration guide before attempting an upgrade.