Releases: mswjs/msw
Releases · mswjs/msw
v0.27.1
Changes
- Exports the
RestHandler
class publicly.
Bug fixes
- Fixes an issue that caused a
Uncaught ReferenceError: process is not defined
exception when callingworker.start()
(#609, #629). - Fixes an issue that caused a TypeScript violation in the
PickLastInTuple
type (#615, #627). - Fixes an issue that caused an
TypeError: Object.fromEntries is not a function
error when running MSW in Node.js v10 (#625, #633).
Internals
- Updates to
[email protected]
v0.27.0
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).
Internal
v0.26.2
Bug fixes
- Fixes an issue that resulted in GraphQL request handlers not annotating the mocked response structure based on the given generic type (#587).
- Fixes an issue when a one-time request handler (
res.once
) affected multiple matching requests made in parallel (#583). - Properly exports the renamed
OnUnhandledRequest
type as the newUnhandledRequestStrategy
type (#577).
v0.26.1
Features
onUnhandledRequest
option will now suggest similar request handlers based on the URL/operation name similarity (#560).
Bug fixes
- Fixes an issue that resulted in a 202 status response throwing an exception when the library attempted to re-create its
Response
instance for theresponse:*
life-cycle event (#570). - Fixes an issue when a request handler stack trace wasn't handled properly on Windows machines (#566).
- Fixes an issue when using the
onUnhandledRequest: "error"
option resulted in a thrown exception being gracefully handled by Axios (#544). The"error"
value now prints tostderr
directly instead of throwing an exception. An original request-related exception will become visible now as well.
v0.26.0
This release introduces changes to the
mockServiceWorker.js
file. Please follow the instructions in the browser to update the worker file. Thank you.
Features
- Adds support for GraphQL upload and multipart data operations (#215, #543).
- Adds delay modes: “real” and “infinite” (#538). Supports infinite loading.
ctx.delay() // random realistic response time
ctx.delay('real') // the same as `ctx.delay()`
ctx.delay('infinite') // infinite response time
ctx.delay(50) // explicit response delay (50ms)
Bug fixes
- Fixes an issue that resulted in the
Failed to construct 'Response': The status provided (0) is outside the range [200, 599].
exception caused by an opaque response on the page (#529, #564). MSW will now skip opaque responses during the life-cycle events handling. You will not get theresponse:bypass
invoked upon an opaque response. - Fixes an issue that resulted in an exception being thrown when handling subsequent requests in Safari (#558, #565).
- Fixes an issue when the
ExecutionResult
ofgraphql
was not compatible withctx.data
andctx.errors
utilities (#522, #542). - Fixes an issue that resulted in the MSW worker handling unrelated message event originating from other tools (#551).
Internal
v0.25.0
v0.24.4
v0.24.3
v0.24.1
v0.24.0
Breaking changes
ctx.json
context utility now always stringifies the response body (#468).- Removes JSON response body transformer as the default response body transformer. Nothing implicitly transforms the response body now.
Migration guidelines
- Replace custom response transformers that might have affected the end response body, such as custom serializers, with custom response transformers.
Bug fixes
- Fixes an issue that resulted in a response body being stringified twice (#466).