-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify the setup and usage of msw in stories #34450
Comments
msw-storybook-addon seems to have problems with resetting the handlers between rendering stories, see mswjs/msw-storybook-addon#82. In the |
Closed with #44041 |
@ravicious I believe this is closed with the v8 upgrade. We only pull msw from the package now, and localhost and the IP work for me (assuming correct certs are used). Can you confirm? |
Yep, that's now addressed by correctly initializing msw! |
Currently, we use msw both from
window.msw
(example) and by importing it from the msw package (example).The version from the window seems to work only over local IP. If
ctx.delay
is used in the msw handlers, it seems to have no effect – the responses are returned immediately.The version from the msw package works only over localhost. It requires a different setup which is currently done per story, but according to the docs it should be done globally in
preview.js
.ctx.delay
seems to work with this version with no problems.This causes problems when viewing stories because some work only in localhost and some work only over local IP.
I haven't tried to understand the use case behind the window version of msw, but since
ctx.delay
doesn't seem to work with it, I believe we should migrate to the second approach. Perhaps it's possible to make it support both the local IP and localhost, so that no matter how someone launches the storyybook, the stories will work.The text was updated successfully, but these errors were encountered: