Packages

msw

3.0.7 · 18 Nov 2026MIT36.1M / weekRepositoryHomepagenpmAtom feed

Your version

0.44.0

13 Jul 2022Where it was published

0.49.3 is the newest release of 0.44.x.

In short

3 breaking1 deprecated1 new5 changed

  • Breaking

    req.destination default value is now "" (empty string), previously "document".

  • Breaking

    req.redirect default value is now ""follow", previously "manual".

  • Breaking

    The library no longer exports the parseIsomorphicRequest() function (#1316). Please use MockedRequest class instead.

  • Deprecated

    req.body is deprecated. Please use explicit request body reading methods: req.text(), req.json(), req.arrayBuffer() (other methods, like req.formData() are currently not supported).

Release note

Breaking changes

  • Breaking

    req.destination default value is now "" (empty string), previously "document".

  • Breaking

    req.redirect default value is now ""follow", previously "manual".

  • Breaking

    The library no longer exports the parseIsomorphicRequest() function (#1316). Please use MockedRequest class instead.

Features

  • Adhere to Fetch API "Request" in response resolver (#1316, @95th) (fc7f00c). This means the addition of a few properties on the req instance:

    • req.priority, indicates a priority of request relatively to other requests (default "auto");

    • req.text(), reads the request body as plain text;

    • req.json(), reads the request body as JSON;

    • req.arrayBuffer(), reads the request body as ArrayBuffer;

    • req.clone(), clones a request instance (i.e. so its body could be read multiple times).

  • Remove unnecessary stringification of worker-client messages

Deprecations

  • Deprecated

    req.body is deprecated. Please use explicit request body reading methods: req.text(), req.json(), req.arrayBuffer() (other methods, like req.formData() are currently not supported).

rest.post('/user', async (req, res, ctx) => {
  const newUser = await req.json()
})

req.body is still present for compatibility reasons but will be removed in the next releases.

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.