Add support for node environments
See original GitHub issueStorybook is awesome, and so is msw. I wrote @storybook/testing-react to allow users to completely reuse stories in tests, so that people don’t need to create similar setups twice. The library has incredible potential to work very efficiently with this addon, as long as it somehow supports non-browser environments. I have tweaked slightly with it and it has worked perfectly.
This is the change:
export function initializeWorker(options) {
if (typeof global.process === 'undefined') {
worker = setupWorker();
worker.start(options);
} else if (maybeSomeFlagHere) {
worker = setupServer();
worker.listen(options);
}
}
After talking to @kettanaito, I am enthusiastic to bring a PR with the changes, as well as making more improvements to this addon. I’m wondering if the fallback to node support should be opt-in, opt-out or just default.
What are your thoughts on all of this? 😄
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Setting up a Node development environment - MDN Web Docs
Adding dependencies · First create a directory for your new application and navigate into it: · Use the npm init command to create...
Read more >Add standardized support information to your Node.js modules
The easiest way to add this standardized information to your Node.js modules is to create a separate file called package-support.json , which ...
Read more >Working with Environment Variables in Node.js - Twilio
Environment variables are a great way to configure parts of your Node.js application. Learn how to work with them using helpful tools such ......
Read more >Node JS Environment Setup - Node.js installation - DigitalOcean
Node JS Base Environment Setup on Windows · Please click on “INSTALL” button to download latest Node JS Platform Version 0.12. · Please...
Read more >Customizing Node.js .env files - LogRocket Blog
Learn how to configure a Node.js application via environment variables and customize an .env file with new environment variables.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @kettanaito that news warms my heart ❤️ I just tested out in my project and it’s just
1 - Deprecation notice to use
initialize
method instead ofinitializeWorker
2 - Tests work wonderfully and beautifully in node@winkerVSbecks @beaussan time to try this out 🎉
Closing the issue now! Thanks a lot for this journey @kettanaito!
msw-storybook-addon@1.2.0
has been successfully published (see release notes).@yannbf, should we close this issue?