msw

Seamless REST/GraphQL API mocking library for browser and Node.js.

MIT License

Downloads
15.7M
Stars
14.9K
Committers
153

Bot releases are hidden (Show)

msw -

Published by kettanaito over 4 years ago

Bug fixes

  • Fixes an issue that resulted into the library's bundle not being tree-shakable (#110, #138)
msw -

Published by kettanaito over 4 years ago

Bug fixes

  • Fixes an issue that resulted into no request parameters being returned when matched against a URL with query parameters (#130, #141).
  • Fixes an issue that resulted into SyntaxError: Invalid regular expression: invalid group specifier name exception in Safari and Firefox due to the usage of a negative lookbehind token in RegExp internally (#142, #143)
msw -

Published by kettanaito over 4 years ago

This release introduces change to the service worker file. Please follow the instructions in your browser's console to update the worker file in your project. Thank you.

Bug fixes

  • Fixes an issue that resulted into ctx.delay() not delaying the mocked response (#136, 137)
msw -

Published by kettanaito over 4 years ago

Bug fixes

  • Fixes an issue that resulted into npx msw init command throwing an error upon successful copying of the worker file (#132, #133)
msw -

Published by kettanaito over 4 years ago

Bug fixes

  • Fixes an issue that resulted into infinite page loading when refreshing a page with "Update on reload" Service Worker option set in Chrome (#119, #129)
  • Fixes an issue that resulted into disabled mocking when hard reloading a page with multiple same host pages opened (#122, #126)
  • Fixes an issue that resulted into service worker file not being copied when run npx msw init command (#130, #131)
msw -

Published by kettanaito over 4 years ago

Bug fixes

  • Fixes an issue where hard reload of a page with multiple pages controlled by MSW were opened resulted into mocking not working (#122, #126)
msw -

Published by kettanaito over 4 years ago

Changes

  • The usage of composeMocks() function is deprecated. Please use the setupWorker() function instead:
- import { composeMocks, rest } from 'msw'
+ import { setupWorker, rest } from 'msw'

- const { start } = composeMocks(...)
+ const { start } = setupWorker(...)
msw -

Published by kettanaito over 4 years ago

Changes

  • Using start({ quiet: true }) now also silences the mocking activation message (#111, #118)
msw -

Published by kettanaito over 4 years ago

This release bumps the integrity of mockServiceWorker.js. Please follow the error instructions in your browser's console to update the worker file to the latest version.

Breaking changes

  • start() function now accepts an options object:
- start('./custom/sw/path.js', { ... })
+ start({ serviceWorker: { url: './custom/sw/path.js', options: { ... } })

Features

  • start function now support a quiet option, allowing to opt-out from the logs in browser's console (#111, #113)
start({ quiet: true })

Bug fixes

  • Fixes a console error when opening the DevTools (#107, #116)
  • Fixes an error message when opening DevTools (#107).
  • Fixes a TypeScript types issue, which resulted into msw throwing a type violation when used with TypeScript v3.7 (unsupported export * as syntax) (#114, #117, ).
  • Fixes a bug that resulted into broken URL matching when using both path parameters and wildcards in a single path.
  • Fixes a bug that forbid having a one character long path parameters.

Internal

  • Bundle size is 20KB smaller due to removing ramda dependency.
msw -

Published by kettanaito over 4 years ago

This release introduces changes to mockServiceWorker.js file. Upon updating, you will be asked to update your Service Worker file. Please follow the instructions in the browser’s console to update the file.

Features

  • Logs matched requests into browser’s console. Inspect what requests have been mocked, their handler, and the response.
  • Adds support for mocking cookies via ctx.cookie() (#101, #103).
rest.post('/login', (req, res, ctx) => {
  return res(
    ctx.cookie('auth-token', 'abc-123')
  )
})

Bug fixes

  • Prevents Service Worker to persist between different projects on the same host (#96, #99).
  • Prevents Service Worker from bypassing requests after hard reload of the page (#98, #99).
msw -

Published by kettanaito over 4 years ago

This change would bump the integrity of the Service Worker. Please follow the instructions in the respective error message in your browser's console to update the Service Worker file.

Features

  • The library now handles exceptions from request handlers as 500 responses (#80, #91)

Internal

  • Updates the library's dependencies (#92)
msw -

Published by kettanaito over 4 years ago

This release introduces changes to the mockServiceWorker.js file. You will be advised to update that file in your application. Please follow the instructions in the related error message in your browser's console.

Bug fixes

  • Fixes an issue when the Promise returned from calling the start() function would resolve sooner than the Service Worker enabled the mocking (#73, #90)
msw -

Published by kettanaito over 4 years ago

This release introduces changes to the mockServiceWorker.js file. You will be advised to update that file in your application. Please follow the instructions in the related error message in your browser's console.

Bug fixes

  • Fixes the Response patching scenario when performing an original POST request performed a GET request instead (#77, #84)
msw -

Published by kettanaito over 4 years ago

Changes

  • Failed integrity assertions now leave the mocking enabled for the purpose of better developer experience (#87). It's still highly recommended to update your Service Worker in that case, but for the sake of backwards-compatible changes it's not mandatory.
msw -

Published by kettanaito over 4 years ago

Features

  • The library now runs an integrity check against the Service Worker registered in your application (#81). This is necessary to warn you when the Service Worker must be updated according to the latest published release of the library. Please follow the update instructions when such occur in your browser's console.
msw - 0.9.0

Published by kettanaito over 4 years ago

Features

  • Added support for Response patching
  • Mocked req object now contains new properties: integrity, destination, keepalive, bodyUsed

Bug fixes

  • Fixed an issue that resulted into req.params being null, causing an exception when trying to access an existing parameter
msw -

Published by kettanaito over 4 years ago

Features

  • Running start() and stop() functions now returns a Promise that corresponds to the Service Worker registration/unregistration status
import { composeMocks, rest } from 'msw'

const { start, stop } = composeMocks(
  rest.get(...)
)

start.then(() => {/* Your logic here */})
stop.then(() => {/* Your logic here */})
msw -

Published by kettanaito over 4 years ago

Fixes

  • Demands a command to be run with npx msw (#61)
  • Improves CLI output when run npx msw init command (#61): outputs the link to the docs
msw -

Published by kettanaito over 4 years ago

Features

  • Request URI matching now ignores trailing slashes (#57, #62)
msw -

Published by kettanaito over 4 years ago

Features

  • Adds support for mocking GraphQL queries and mutations (#45)

Tutorials