reactjsstorybookmsw

What's the difference between the MSW Storybook Addon and storybook-addon-mock?


I need to mock API requests in my Storybook environment, I found 2 libraries for the job, MSW Storybook Addon and storybook-addon-mock, they all look the same to me, I'm not sure which one to use and why use one over another one, any difference between these 2 libraries?

https://github.com/mswjs/msw-storybook-addon

https://github.com/linearlabs-workspace/storybook-addon-mock

I read the official docs, I want to know the difference between them.


Solution

  • Both packages help to mock API requests in the Storybook environment.

    msw-storybook-addon is a specific package to use MSW. The one way to decide to use one over the other is to answer those questions:

    1. Do you already use MSW to mock API requests?
    2. In case you do not use MSW yet, do you consider to use it? The benefit of doing so, you can have shared handlers and reuse them for integration tests/e2e tests/storybook. Which makes general app architecture cleaner.