mswjs / msw-storybook-addon

Mock API requests in Storybook with Mock Service Worker.
https://msw-sb.vercel.app
MIT License
408 stars 39 forks source link

Feature: Support React Native environments #115

Closed SethDavenport closed 1 year ago

SethDavenport commented 1 year ago

Now that @storybook/react-native has reached compatibility with storybook 6, it supports CSF, which means we can almost use this decorator for react native storybooks!

There's just one missing piece: the initialize function needs to call setupServer from msw/native in a ReactNative environment. Credit to this post for that part.

This PR adds a special case for react native next to the existing DOM and Node initialization code.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
msw-storybook-addon ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 26, 2023 7:56am
SethDavenport commented 1 year ago

What can I do to help move this along?

github-actions[bot] commented 1 year ago

:rocket: PR was released in v1.10.0 :rocket:

Coffeegerm commented 1 year ago

Few questions trying to use this in our application.

Does the usage of this in React Native require that you have a different entry point into Storybook over navigating to it from within your running application?

Do you have to specify the full route you're calling in your handlers? For example will */values catch a call or do i need to specify the base url as well instead of *

The docs show us putting this in the loaders, but what the init of sb in react native gives us does not show anything about this. Should we instead use the mswDecorator still?