InfoQ Homepage News Mock Service Worker Releases v3.0 with ESM-Only Build, Socket-Based Interception and GraphQL Subs.

Nov 26, 2026 2 min read.

Mock Service Worker, the API mocking library maintained by Artem Zakharchenko, has released version 3.0, nearly three years after the Fetch-based v2.0 rewrite. The release ships as ESM-only, completes the library's GraphQL story with subscription support, and introduces a socket-based interception algorithm in Node.js that Zakharchenko describes as going as deep into the runtime as JavaScript will allow without recompiling Node.

It has been revealed that the headline breaking change is that MSW is now distributed natively as ECMAScript Modules only, with support for Node.js v18 and v20 dropped in favour of v22, v24, and v26. TypeScript 5.9 is now the minimum supported version. Several transitive dependencies have been removed, including graphql (now a proper optional peer), path-to-regexp, picocolors, and statuses. The result is a library tarball that drops from 416KB to 234KB, with type definitions shrinking by half, from 190KB to 90KB.

Alongside ESM, v3.0 introduces granular entrypoints that replace the single msw import with designated paths for each protocol:.

GraphQL subscription support, a long-standing community request on the project's tracker, lands in this release. Building on the WebSocket interception shipped previously, subscription handlers can now be defined against a graphql.link() and publish events on demand, closing the gap between MSW's HTTP, WebSocket, and GraphQL coverage.

An experimental defineNetwork API is introduced as the eventual replacement for setupServer and setupWorker. The upcoming primitive splits interception into sources (where traffic comes from) and handlers (how it is answered), allowing teams to replay HAR files, combine custom interceptors, or hand control of request timing to a test runner. The first ecosystem package to expose it directly is @msw/cloudflare, which wraps the API for Workers environments.

In a recent development, the most technically significant change sits in the underlying Interceptors library. Zakharchenko writes that after seven attempts at the problem, the team has moved network interception in Node.js down to the TCP and TLS wraps, the JavaScript bindings for Node's C-level network code. Moving any lower, he notes, would require recompiling Node.js itself. The latest architecture supports arbitrary socket-based protocols, with SMTP cited as an early example. Nock already relies on the Interceptors library for its Node.js support.

Recent findings suggest that A GitHub discussion reports failing tests after upgrading, traced to MSW now intercepting the browser-issued OPTIONS preflight requests that previous versions quietly ignored. Separately, a developer in discussion #2771 challenged the earlier decision to deprioritise Jest and JSDOM, arguing that a runner with 46 million weekly downloads warrants a formal breaking-change note rather than a quiet docs change.

In the Node-only space, MSW continues to compete with Nock, fetch-mock, and undici's built-in MockAgent, though as a recent comparison notes, none of those cover both browser and server with a single handler definition.

According to recent reports, teams on v2 should consult the official 2.x to 3.x migration guide before upgrading. Full release notes are available on GitHub.

According to recent reports, mock Service Worker is an open-source, MIT-licensed JavaScript library for mocking network traffic using Service Workers in the browser and runtime-level interception in Node.js. It is used widely for frontend and full-stack testing, and now covers HTTP, WebSocket, Server-Sent Events, and GraphQL including subscriptions.

Sources indicate that equal Experts helps organizations harness AI, modernize technology, and build better software through expert engineering, collaboration, and innovative delivery practices. Learn more.

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example.

→ Read original article