-
Notifications
You must be signed in to change notification settings - Fork 39
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
Support for MSW 2.0.0 #121
Comments
Edit: Please use Hey everyone! I started the changes in #122, and there's a canary release ready for you to try:
It might take some time to promote it to latest (and therefore release a breaking change), so please use the canary and let me know how it goes! |
Working great so far, thanks @yannbf! |
this has been working well for me too @yannbf - been using it for a few weeks now |
been using the canarary for a little bit now and haven't noticed any issues so far 👍 |
any plans when it goes stable? thanks. |
Hey @szykov 👋 We're just getting back from holidays. I'll talk to Yann about getting this merged over the next week or so. Stay tuned 📻 |
Hey everyone! Unfortunately there are still a few things to sort out before the addon releases breaking changes (v2.0.0) to latest.
|
FYI, I tried to upgrade from the canary to the beta and hit #131. Canary works fine. |
@CHE1RON import { initialize } from 'msw-storybook-addon'
initialize({
onUnhandledRequest: 'bypass'
}) https://github.com/mswjs/msw-storybook-addon?tab=readme-ov-file#configuring-msw see also: |
That's EXACTLY what I needed, thank you very much! 🥇 |
@csantos1113 any chance to release a new beta? |
@chiptus - I can't answer that because I'm not a maintainer of this package 😅 |
Hey everyone! We just released a new beta version that should be improved and also not display such warnings anymore @CHE1RON @mocaffy you won't need that workaround anymore. |
It works! Thank you!! For those who try it out, be very careful with your version specification in package.json. There's a "next" version of 2.0.0, I set my version pin to just "beta", so I'll get future beta upgrades. |
This addon in its
It's canary version works fine. |
@SalahAdDin Yes, don't use next, use beta. See my comment right above yours. #121 (comment) |
mocks are not working for me in this beta version. it's working fine in canary version though. |
@adnan-sheikh Can you provide any sample code? It's working fine for me, so I'm curious what might not work on your end 😉 |
Conditional exports still need adjusting. I am importing from
And yet the package works completely fine when I run Storybook. TypeScript just can't see it at all. Looking at "main": "./dist/index.browser.js",
"types": "./dist/index.browser.d.ts",
"exports": {
"browser": {
"types": "./dist/index.browser.d.ts",
"default": "./dist/index.browser.js"
},
"react-native": {
"types": "./dist/index.react-native.d.ts",
"default": "./dist/index.react-native.js"
},
"node": {
"types": "./dist/index.node.d.ts",
"default": "./dist/index.node.js"
}
}, I think TypeScript will only look inside a Node.js docs have this to say on the subject:
Given this, the simplest solution is to add a
A possibly better option would be to align with MSW v2's "exports": {
"./browser": {
"node": null,
"types": "./dist/index.browser.d.ts",
"default": "./dist/index.browser.js"
},
"./node": {
"browser": null,
"types": "./dist/index.node.d.ts",
"default": "./dist/index.node.js"
},
"./native": {
"browser": null,
"types": "./dist/index.react-native.d.ts",
"default": "./dist/index.react-native.js"
}
}, This would mean users would import from a subpath, just like MSW itself; but this is a major release, and it could be a nice bit of API parity with the base library. |
The stories seem to be working with the beta version, but it fails to run tests with the error Invariant Violation: [MSW] Failed to execute I noticed that the old addon contained a mswDecorator.js file which determined wether to load the worker or the server based on the environment (node vs browser), but the beta version has non such things. What is the recommended way to initialize in |
Actually what aaronadamsCA suggested worked for me, both for browser environment and for running tests. Could you add that to the beta release?
|
Hey everyone! Finally the major version is out. Sorry for such a long wait, I had to make sure the addon aligned with Storybook 8 and worked correctly in the portable stories (using stories in Vitest,Jest) scenario. Please check the release notes, try it out and provide feedback in case issues arise: Thanks! |
any migration guide? |
It's in the link in the message you've quoted |
I still have an issue running jest tests, because somehow it uses the 'default' export from the package.json and not the 'node'. |
Hey guys, I noticed mswjs/msw#1464 (mswjs/msw#1436) is hopefully getting released this month 🤞, and I'm wondering if there is any work in progress to get
msw-storybook-addon
working with it?Thanks
The text was updated successfully, but these errors were encountered: