Breaking changes
- The Promise returned by
worker.start()
will now reject in the case of any errors during the worker registration (#607). - The library no longer exports the following TypeScript declarations:
RestRequestType
, useRestRequest
instead.GraphQLMockedRequest
, useGraphQLRequest
instead.GraphQLMockedContext
, useGraphQLContext
instead.GraphQLRequestPayload
, useGraphQLRequestBody
instead.GraphQLRequestParsedResult
, useParsedGraphQLRequest
instead.GraphQLResponseResolver
- The values of the
MockedRequest
type no longer have theparams
key (#561). Please use theRestRequest
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).