Hey, Jakub! Thank you for writing this pieace on using RTK Query and MSW!
There's but one thing I may suggest: split the setup step into polyfills and MSW setup. You add the following polyfills not because MSW needs them, but because your test environment needs them:
You're testing code that's meant to run in a browser, so it relies on browser's globals like fetch or Headers or Request. That is why you add polyfills.
Such separation in the same testing setup step is essential for people to better understand what they're adding to the setup and why.
Hey, Jakub! Thank you for writing this pieace on using RTK Query and MSW!
There's but one thing I may suggest: split the setup step into polyfills and MSW setup. You add the following polyfills not because MSW needs them, but because your test environment needs them:
You're testing code that's meant to run in a browser, so it relies on browser's globals like
fetch
orHeaders
orRequest
. That is why you add polyfills.Such separation in the same testing setup step is essential for people to better understand what they're adding to the setup and why.
Regardless, I've enjoyed reading this one!
Hey, I'm glad you liked this article and thanks for the suggestion. I updated the content