Node.js
Content type: News
5 min read
Mock Service Worker 3.0 arrives in pure ESM and intercepts network traffic down to the TCP/TLS layer in Node.js
Mock Service Worker, widely used in frontend and full-stack testing, becomes ESM-only, cuts the package size by almost half, and starts intercepting traffic at the socket level, affecting anyone testing integration with HTTP, WebSocket, and GraphQL APIs.
- Reading
- 5 min
- Code
- 1
Mock Service Worker, widely used in frontend and full-stack testing, becomes ESM-only, cuts the package size by almost half, and starts intercepting traffic at the socket level, affecting anyone testing integration with HTTP, WebSocket, and GraphQL APIs.
Mock Service Worker, widely used in frontend and full-stack testing, becomes ESM-only, cuts the package size by almost half, and starts intercepting traffic at the socket level, affecting anyone testing integration with HTTP, WebSocket, and GraphQL APIs.
Mock Service Worker, a network mocking library maintained by Artem Zakharchenko, released version 3.0 this Thursday (26), nearly three years after the Fetch-based 2.0 rewrite. The update touches three fronts at once: package distribution, protocol coverage, and the depth of interception in Node.js, according to reporting by InfoQ.
For those who use MSW to test API integration on a daily basis, the announcement is not just a version bump. It reorganizes how the package is imported, raises the project's compatibility floor, and introduces an interception mechanism that the team itself describes as the deepest possible within the Node runtime without recompiling Node itself.
ESM-only and the package diet
The change most likely to break builds is native distribution exclusively in ECMAScript Modules. Support for Node.js 18 and 20 was dropped in favor of 22, 24, and 26, and the minimum supported TypeScript version rises to 5.9. Projects still running pure CommonJS, or locked to older Node versions in CI, will need to migrate before updating MSW.
The team also removed transitive dependencies that were bloating the package: graphql became a truly optional peer dependency, and path-to-regexp, picocolors, and statuses were dropped entirely. The practical result is a tarball that drops from 416KB to 234KB, a reduction of about 44%. The type definitions shrank even more, from 190KB to 90KB, nearly half.
For teams that run npm audit in their pipeline or monitor the size of node_modules in CI, this means less transitive dependency surface to audit with every release.
Granular entry points per protocol
The single msw import gives way to dedicated paths per protocol, which makes tree-shaking more predictable and the test bundle leaner when a project only uses part of the API:
import { http } from 'msw/http'
import { graphql } from 'msw/graphql'
import { sse } from 'msw/sse'
import { ws } from 'msw/ws'In practice, this forces a small rewrite of imports in any test suite that currently imports everything directly from msw, but it reduces what needs to be loaded when a project only mocks HTTP, for example.
GraphQL gains subscriptions
Version 3.0 closes a long-standing community request: support for GraphQL subscriptions. Built on top of the WebSocket interception that already existed in previous versions, it is now possible to define subscription handlers against a graphql.link() and publish events on demand in tests. With this, MSW's protocol coverage closes the loop between HTTP, WebSocket, Server-Sent Events, and GraphQL, including subscriptions.
Interception at the TCP/TLS layer
The most technically relevant change is in the Interceptors library, used internally by MSW. According to InfoQ, Zakharchenko wrote that, after seven previous attempts, the team managed to move network interception in Node.js down to the TCP and TLS wraps, the JavaScript bindings for Node's own low-level networking code written in C. Going any deeper than that, he said, would require recompiling Node.js itself.
The new architecture now supports arbitrary socket-based protocols, with SMTP cited as an initial example of application. The Nock library already depends on Interceptors for its Node.js support, which means the change indirectly benefits other mocking tools in the ecosystem, not just MSW itself.
defineNetwork: the experimental successor to setupServer
The release also introduces, experimentally, an API called defineNetwork, intended to eventually replace setupServer and setupWorker. The proposal splits interception into two parts:
- sources: where the traffic comes from;
- handlers: how it is responded to.
This opens room for replaying HAR files, combining custom interceptors, or delegating request timing control to the test runner. The first package in the ecosystem to expose this API directly is @msw/cloudflare, aimed at Cloudflare Workers environments.
What's still open
Not everything in the release is a smooth consensus. An open discussion on the project's GitHub reports tests breaking after the upgrade: MSW 3.0 started intercepting the OPTIONS preflight requests triggered by the browser, something previous versions simply ignored.
There is also friction around support for older runners. In discussion #2771 of the repository, a developer questioned the decision to deprioritize Jest and JSDOM, arguing that a runner with 46 million weekly downloads deserved a formal breaking-change notice, not just a silent change in the documentation.
Where MSW still competes
In the Node.js-only universe, MSW continues to compete with Nock, fetch-mock, and the MockAgent built into undici. According to InfoQ, a recent comparison points out that none of these alternatives cover browser and server with the same handler definition, a differentiator MSW keeps by running in both environments with the same API.
For those who maintain a test suite that runs on both Jest/Vitest and browser E2E tests, this dual coverage remains the main reason to stick with MSW instead of switching to a Node-only tool.
How to migrate
Teams on the 2.x line should consult the official 2.x-to-3.x migration guide before updating, especially projects that depend on CommonJS, run Node 18 or 20 in CI, or have large Jest-based test suites with JSDOM. The full release notes are available in the project's GitHub repository.
Translated from the Brazilian Portuguese original · Read the original
Vercel launches experimental board to coordinate humans and code agents
Vercel Board tries to solve a problem the entire market is still feeling its way through: how humans and code agents like Claude Code, Codex, and Copilot share the same task board without stepping on each other's work.





