Thanks @Redhwan Nacef , you made it very clear and simple will be very useful for web projects , especially making it as dev environment was awesome, it saves lot of time and effort.
Thanks. Hmm, good question, I don't think there is a way to do it out of the box, however maybe you could reuse the handlers to return responses for a real api?
Thanks for the tutorial! If the service worker is started and stopped within each test section will this add a lot of extra overhead time when running an entire test suite of maybe say a few hundred tests?
You're welcome. I think any overhead will be negligible when testing. Running tests happens within the node environment instead of the browser, so no actual service worker exists, MSW have a node implementation that will mock the network requests. Also, when running tests you would usually start/stop the mock server at the start and end of the entire test run, the only thing that happens after each tests is resetting the handlers. With this in mind I don't think there is really anything that would add much overhead. Hope that makes sense.
Hi Redhwan, where do you mock your database etc in order to mock a proper Restful API with proper business data. I assume that you simply store it locally
I tried this in my react unit tests. But server is not listening to rest.post call so instead of making mocked api call its making actual axios api call.
Note: you no longer have to add the 'jest-environment-jsdom-sixteen' test environment with the latest version of CRA/react-scripts.
Great video, thanks for the bit at the end on using it in standard dev. Whats especially good is that the same handlers can be used for dev and test.
Thank you. Yea I agree, it can make local development a lot easier.
Thank you! now it became much clear how to use MSW in test and development
You’re welcome! Happy it helped.
Thanks @Redhwan Nacef , you made it very clear and simple will be very useful for web projects , especially making it as dev environment was awesome, it saves lot of time and effort.
You’re welcome, thanks for the feedback.
You gave me a new vision ... thanks
Glad it helped!
Great tutorial, thanks
Thanks, glad you enjoyed it.
Hi
Nice Video. I have a query , is it possible to expose these API to public way(means can everyone utilize this APIs)
Thanks. Hmm, good question, I don't think there is a way to do it out of the box, however maybe you could reuse the handlers to return responses for a real api?
Thanks for the tutorial! If the service worker is started and stopped within each test section will this add a lot of extra overhead time when running an entire test suite of maybe say a few hundred tests?
You're welcome. I think any overhead will be negligible when testing. Running tests happens within the node environment instead of the browser, so no actual service worker exists, MSW have a node implementation that will mock the network requests. Also, when running tests you would usually start/stop the mock server at the start and end of the entire test run, the only thing that happens after each tests is resetting the handlers. With this in mind I don't think there is really anything that would add much overhead. Hope that makes sense.
Hi Redhwan, where do you mock your database etc in order to mock a proper Restful API with proper business data. I assume that you simply store it locally
Hi, yes that's right I would usually use an in memory database or stub/mock those responses manually.
Thanks man
Any time
Like and comment for algorithm.
Thanks! Somehow missed this comment all those month ago…
I tried this in my react unit tests. But server is not listening to rest.post call so instead of making mocked api call its making actual axios api call.
Sounds like something is not set up right. If you are able to share the code with me, I would be happy to take a look.
What VSCode extensions are you using?
I’m using IntelliJ here instead of VSCode
Can mock Eventsource?
Good question, I am not sure I'm afraid, something to look into. I haven't seen first class support anywhere from MSW but maybe there is a way...
@@RedhwanNacef i tried to look for that nd Found out npm mock sse but unfortunately it didn't Work, plz if possible try for that
reading documentation, yaay
😂