question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for node environments

See original GitHub issue

Storybook 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:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
yannbfcommented, Jul 14, 2021

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 of initializeWorker 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!

0reactions
kettanaitocommented, Jul 14, 2021

msw-storybook-addon@1.2.0 has been successfully published (see release notes).

@yannbf, should we close this issue?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found