Closed tofumatt closed 4 years ago
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:
Feature Description
We currently use jest-fetch-mock for all of our mocking of
window.fetch
requests in ourjest
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 withfetch-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.
Acceptance criteria
fetch-mock-jest
is added topackage.json
and existing tests are migrated to use it over our existingjest-fetch-mock
tests.jest-fetch-mock
is removed frompackage.json
(optional; only do if we can entirely replace the other mock library)Implementation Brief
fetch-mock-jest
's bettertoHaveFetched(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.QA Brief
Changelog entry