Skip to content

Releases: mswjs/msw

v0.27.2

23 Mar 15:20
Compare
Choose a tag to compare

Bug fixes

  • Fixes a backward-compatibility issue of the DropFirstInTuple type used internally in compose.ts (#658).
  • Fixes an issue in IE11 when retrieving a stack trace of a handler would throw an exception (#647).
  • Fixes an issue when a stream in a response body would cause a response timeout (#602).
  • Fixes an issue when a cookie retrieval would cause a Fast Refresh to break in Next.js (#649).

v0.27.1

08 Mar 13:57
Compare
Choose a tag to compare

Changes

  • Exports the RestHandler class publicly.

Bug fixes

  • Fixes an issue that caused a Uncaught ReferenceError: process is not defined exception when calling worker.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 typescript@4.2.2

v0.27.0

25 Feb 12:13
Compare
Choose a tag to compare

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, use RestRequest instead.
    • GraphQLMockedRequest, use GraphQLRequest instead.
    • GraphQLMockedContext, use GraphQLContext instead.
    • GraphQLRequestPayload, use GraphQLRequestBody instead.
    • GraphQLRequestParsedResult, use ParsedGraphQLRequest instead.
    • GraphQLResponseResolver
  • 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).

Internal

  • Rebuilds the Request Handler API from ground-up (#561). Does not introduce any breaking changes in how you use the handlers.
  • Fixes the auto-imports of the library’s methods suggested by IDE (#598).
  • Updates the dependencies.

v0.26.2

08 Feb 23:19
Compare
Choose a tag to compare

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 new UnhandledRequestStrategy type (#577).

v0.26.1

02 Feb 12:21
Compare
Choose a tag to compare

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 the response:* 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 to stderr directly instead of throwing an exception. An original request-related exception will become visible now as well.

v0.26.0

26 Jan 16:44
Compare
Choose a tag to compare

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)
  • Displays [MSW] Mocking disabled message when calling worker.stop(). (#485, #493).

Bug fixes

  • Fixes an issue that resulted in theFailed 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 the response: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 of graphql was not compatible with ctx.data and ctx.errors utilities (#522, #542).
  • Fixes an issue that resulted in the MSW worker handling unrelated message event originating from other tools (#551).

Internal

  • Updates dependencies to their latest versions.
  • Consistently uses self instead of this in the worker script (#568).
  • Ensures that MSW doesn’t handle events originating from unrelated workers (#551).

v0.25.0

04 Jan 09:42
Compare
Choose a tag to compare

Features

  • Adds Life-cycle events API (#482, docs).

v0.24.4

30 Dec 09:10
Compare
Choose a tag to compare

Features

  • Exports the RestContext type interface for public consumption (#524).

v0.24.3

27 Dec 09:56
Compare
Choose a tag to compare

Features

  • Publishes the library in IIFE format, allowing to use it from a <script> tag (#507, #509).

Internal

  • Updates package's dependencies (#521).

v0.24.1

01 Dec 09:46
Compare
Choose a tag to compare

Improvements

  • Ships with refined JSDoc support (#483). Most of the core functions and methods now include concise description, usage example, and a link to the docs.