mock service worker integration in storybook-build
See original GitHub issueFirst of all, thanks for creating this addon, It’s being really useful overall. However, I have a specific use case where when building storybook with the default build-storybook
command, which generates the storybook-static
folder, I want to be able to get data from the mock service provider.
Right now, when the build finishes, the mock service provider doesn’t work (can’t fetch any data).
How could I make it work within the build?
I want this behaviour because I can just send to my clients a link to check how the frontend is looking right now, which is the storybook build, and having no mocks in it will provide them nothing useful.
Issue Analytics
- State:
- Created 2 years ago
- Comments:19 (7 by maintainers)
Top Results From Across the Web
Using Storybook and Mock Service Worker for mocked API ...
In this tutorial, you can learn about the synergy between Storybook and Mock Service Worker and how to integrate them together seamlessly.
Read more >MSW Storybook Addon - Mock Service Worker
Generate service worker for MSW in your public folder. If you already use MSW in your project, you have likely done this before...
Read more >How to mock APIs in Storybook with MSW (Mock Service ...
Create a Storybook public folder; Install Mock Service Worker (MSW); Create a mock in a story; Bonus: use local images in your stories ......
Read more >Storybook and Mock Service Worker, a match made in heaven
And as you'll know if you read my blog post about integration testing, Mock Service Worker is also a very powerful tool for...
Read more >Integration stories: elevating Storybook with Mock Service ...
Enter Mock Service Worker. Mock by intercepting requests on the network level. Seamlessly reuse the same mock definition for testing, ...
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
A colleague pointed out an unfortunate mistake to me, in that you can see above the
build-storybook
command doesn’t make use of-s .storybook/public
. Adding this made it work, which makes pretty obvious sense as to why the worker file wasn’t in the build 🤦🏻 looks like I was only checking for the-s
flag in the serve command.In any case, thanks for your responses, and for the work on this addon!
Great to know you figured that out @tomcarter17! I’d recommend using the new notation of staticDirs which would have avoided such issue in the first place, as it’s shared between dev and build in Storybook!