Skip to content

Releases: mswjs/msw-storybook-addon

v2.0.2

05 May 14:14
Compare
Choose a tag to compare

🐛 Bug Fix

Authors: 1

v2.0.1

03 May 16:08
Compare
Choose a tag to compare

🐛 Bug Fix

Authors: 1

v2.0.0

17 Apr 10:57
Compare
Choose a tag to compare

Release Notes

BREAKING CHANGE: Support MSW 2.0 (#122)

MSW required version is now ^2.0.0

The addon now requires your MSW version to be 2.0.0 or higher. This means you will have to change the format of your handlers as well. More info on how to migrate to MSW 2.0.0: https://mswjs.io/docs/migrations/1.x-to-2.x/

mswDecorator is deprecated in favor of mswLoader

Using MSW in a decorator worked for most scenarios, but there's a slight chance the service worker will not get registered in time. As a result, a story that requests data might actually request real data. Since v1.7.0, this addon provided a mswLoader to use instead of the mswDecorator. Loaders get executed before a story renders, differently than decorators, which execute as the story renders.

Please replace your mswDecorator with mswLoader, as the mswDecorator will be removed in the next major release. It works the same, respecting the parameters you set, so there's no need to change anything else in your codebase.

// .storybook/preview.js
-import { initialize, mswDecorator } from 'msw-storybook-addon'
+import { initialize, mswLoader } from 'msw-storybook-addon'

initialize()

const preview = {
-  decorators: [mswDecorator]
+  loaders: [mswLoader]
}

export default preview

parameters.msw Array notation deprecated in favor of Object notation

Since v1.5.0, this addon started supporting the parameters.msw.handlers object format instead of using parameters.msw as an Array. This change was done to follow convention for Storybook addon parameters, but also allows for more advanced usage and make the addon more future proof for upcoming features. You can find more information here.

Please migrate to this format, and the previous format will be removed in the next major release.

// ❌ Instead of defining the msw parameter like so:
export const MyStory = {
  parameters: {
    msw: [...] // some handlers here
  }
}

// ✅ You should set them like so:
export const MyStory = {
  parameters: {
    msw: {
      handlers: [...] // some handlers here
    }
  }
}
// ✅ Or like so:
export const MyStory = {
  parameters: {
    msw: {
      handlers: {
        someHandlerName: [...] // some handlers here
      }
    }
  }
}

💥 Breaking Change

🐛 Bug Fix

⚠️ Pushed to main

Authors: 6

v1.10.0

26 Oct 08:02
Compare
Choose a tag to compare

🚀 Enhancement

Authors: 2

v1.9.0

09 Oct 14:39
Compare
Choose a tag to compare

🚀 Enhancement

📝 Documentation

  • Docs: Add troubleshooting section and update reference to statics (#109) [skip-ci] #109 (@yannbf)

Authors: 2

v2.0.0-next.1

14 May 07:40
549798f
Compare
Choose a tag to compare
v2.0.0-next.1 Pre-release
Pre-release

🐛 Bug Fix

Authors: 1

v2.0.0-next.0

09 May 14:53
841fdee
Compare
Choose a tag to compare
v2.0.0-next.0 Pre-release
Pre-release

💥 Breaking Change

  • use tsup for building, migrate to vite, add default handlers #111 (@yannbf)

📝 Documentation

  • Docs: Add troubleshooting section and update reference to statics (#109) [skip-ci] #109 (@yannbf)

Authors: 1

v1.8.0

08 Mar 17:33
Compare
Choose a tag to compare

🚀 Enhancement

🐛 Bug Fix

Authors: 2

v1.7.0

14 Jan 14:03
21d9849
Compare
Choose a tag to compare

1.7.0 (2023-01-14)

Features

Using MSW in a decorator works for most scenarios, but there's a slight chance the service worker will not get registered in time. As a result, a story that requests data might actually request real data. A potential solution to that is to use Storybook loaders. They get executed before a story renders, differently than decorators, which execute as the story renders. This release provides a mswLoader now, so you can replace your decorator with a loader, and potentially fix race conditions you might have. It works the same, respecting the parameters you set, so there's no need to change anything else in your codebase.

// .storybook/preview.js
-import { initialize, mswDecorator } from 'msw-storybook-addon'
+import { initialize, mswLoader } from 'msw-storybook-addon'

initialize()

-export const decorators = [mswDecorator]
+export const loaders = [mswLoader]

v1.6.3

08 Apr 23:17
d64eb49
Compare
Choose a tag to compare

1.6.3 (2022-04-08)

Bug Fixes