We currently use jest-fetch-mock for all of our mocking of window.fetch requests in our jest tests, but after chatting, @aaemnnosttv and I have been finding that libraries functionality and jest-matchers to be a bit lacking. Especially when it comes to checking for request body/param values, the newer fetch-mock-jest has better matchers and a nicer, more flexible API. It also better integrates with fetch-mock, which we're already using in Storybook.
This library was quite new and not well-advertised when we started, but seems well-supported now and we should try to:
jest-fetch-mock._Do not alter or remove anything below. The following sections will be managed by moderators only._
fetch-mock-jest is added to package.json and existing tests are migrated to use it over our existing jest-fetch-mock tests.jest-fetch-mock is removed from package.json (optional; only do if we can entirely replace the other mock library)fetch-mock-jest's better toHaveFetched(filter, options) matcher.fetch mocks in tests to the new API but maintain the test coverage.If we can't remove jest-fetch-mock but can use both and that gives us better flexibility: let's go for that.
I just stumbled across this. Since writing fetch-mock-jest I've found various teething problems which are - I hope - now all resolved. Thought I'd just say hello and let you know I'd be very interested to hear of any feedback you have from migrating. Let me know if anything's buggy and I will try to resolve ASAP.
That sounds good to me, it technically feels like a better alternative. Regarding maintenance, fetch-mock-jest is currently a lot less popular and this could have long-term implications, but since it's new and growing, and since you @wheresrhys already checked in here (thanks!), let's give it a shot! 🎉
IB ✅
QA :heavy_check_mark:
Most helpful comment
I just stumbled across this. Since writing fetch-mock-jest I've found various teething problems which are - I hope - now all resolved. Thought I'd just say hello and let you know I'd be very interested to hear of any feedback you have from migrating. Let me know if anything's buggy and I will try to resolve ASAP.