msw
3.0.7 · 18 Nov 2026MIT36M / weekRepositoryHomepagenpmAtom feed
0.49.3 is the newest release of 0.36.x.
In short
2 breaking6 new4 fixed2 internal
- Breaking
Request path parameters are now annotated as ambiguous
string | string(#999). - Breaking
Relative requests are now resolved against
document.baseURI(previouslylocation.origin) in a browser-like environments (#1007, #1008).
Release note
Breaking changes
- Breaking
Uses path-to-regexp for URL matching (#691, #888). This makes the path matching experience identical to such in ExpressJS, and enabled various new features:
Optional path segments (
/foo/bar?);Repeating groups (
/foo/bar+).
- Breaking
Request path parameters are now annotated as ambiguous
string | string(#999). - Breaking
The
RequestParamsgeneric now follows theRequestBodyTypegeneric, changing its order (#999):
rest.post<RequestBodyType, RequestParams, ResponseBodyType>() {}- Breaking
Removes the
RequestParamstype (#999). Please use thePathParamstype instead.
- import { RequestParams } from 'msw'
+ import { PathParams } from 'msw'- Breaking
Relative requests are now resolved against
document.baseURI(previouslylocation.origin) in a browser-like environments (#1007, #1008).
Features
Adds a new
rest.all()request handler (#896). This handler captures all REST API requests regardless of method.
import { rest } from 'msw'
rest.all('/api/*', (req, res, ctx) => {
// Intercepts all requests to "/api/*"
// regardless of their method.
})graphql.query('GetUser', (req, res, ctx) => {
return res(
ctx.extensions({
message: 'Mocked extension',
tracking: { version: '1.2.3' }
})
)
})Exports
SetupWorkerApiandSetupServerApifrom the browser and Node.js modules respectively (#994).
Bug fixes
Specifies
typescriptas apeerDependencyto control supported TypeScript versions (#985).Fixes an issue that resulted in
graphql.operationhandler producing a warning unable to intercept anonymous operations (#918, #904).Locks
inquirerdependency version to 8.1.5 to propagate the fix for theUnexpected token “?”issue when using MSW CLI (#917).Fixes an issue that resulted in the
TypeError: Failed to execute 'XXX' on 'Response': body stream already readerror when reading the original response body in the fallback mode (#152).
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.