Packages

msw

3.0.7 · 18 Nov 2026MIT36M / weekRepositoryHomepagenpmAtom feed

Your version

0.27.0

25 Feb 2021Where it was published

0.49.3 is the newest release of 0.27.x.

In short

2 breaking3 new2 fixed6 changed2 internal

  • Breaking

    The Promise returned by worker.start() will now reject in the case of any errors during the worker registration (#607).

  • Breaking

    The values of the MockedRequest type no longer have the params key (#561). Please use the RestRequest type to annotate REST API requests instead.

Release note

Breaking changes

  • Breaking

    The Promise returned by worker.start() will now reject in the case of any errors during the worker registration (#607).

  • Breaking

    The library no longer exports the following TypeScript declarations:

    • RestRequestType, use RestRequest instead.

    • GraphQLMockedRequest, use GraphQLRequest instead.

    • GraphQLMockedContext, use GraphQLContext instead.

    • GraphQLRequestPayload, use GraphQLRequestBody instead.

    • GraphQLRequestParsedResult, use ParsedGraphQLRequest instead.

    • GraphQLResponseResolver

  • Breaking

    The values of the MockedRequest type no longer have the params key (#561). Please use the RestRequest type to annotate REST API requests instead.

Features

  • Supports automatic worker script updates (#606). Respects the msw.workerDirectory property in your package.json:

{
  "msw": {
    "workerDirectory": "public"
  }
}

Starting from this release, whenever you install msw, it will try to locate the msw.workerDirectory property in your package.json and copy the relevant worker script (mockServiceWorker.js) to that directory.

Whenever running msw init now, you will be prompted to save your public directory choice to package.json.

  • When running msw init you can pass the —save option to automatically save the public directory in your package.json for future worker updates (#606). You can alternatively use --no-save to bail out this step.

  • Intercepts requests originating from an iframe (#589).

  • Adds virtual cookie store to ensure the persistency of cookies received from the same domains across multiple requests (#435, #469).

Bug fixes

  • Fixes an issue when a request body type generic had no effect on the response composition chain validation.

  • Fixes an issue when a 204 response threw an exception when the library emitted its response:* life-cycle events (#570).

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.