DEV Community

Discussion on: 🚧 Configure MSW in NX

Collapse
 
nareshjbhatia profile image
Naresh Bhatia

Very useful article @iamandrewluca . I was able to get my Nx app running with MSW without any issues. Also got Jest to recognize MSW.

However, having trouble with Storybook. It seems to find the handlers but has trouble loading mockServiceWorker.js. Here's the error message:

MSW Error

Any idea what could be going wrong? Here's my repo. yarn storybook:app to start storybook, then try CartView or CatalogView. You will see "Network Error".

TIA.

Collapse
 
iamandrewluca profile image
Andrei Luca

When your run storybook, it starts standalone without app/lib configuration even if is run through nx.
Your current configuration is specifically for react-test-shop.
You will need to configure msw separately for storybook I think. Take a look at this addon, maybe it will help

storybook.js.org/addons/msw-storyb...

Collapse
 
nareshjbhatia profile image
Naresh Bhatia

Thanks for your response, Andrew. I will take a look. Without Nx in the picture, I have never had to do anything more than starting MSW from .storybook/preview.tsx. For example, in this repo I have the same app working with CRA and Storybook and everything works just fine!!!