google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 291 forks source link

Use fetch-mock-jest over jest-fetch-mock #1477

Closed tofumatt closed 4 years ago

tofumatt commented 4 years ago

Feature Description

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:

  1. add the library and use it going forward for our fetch tests
  2. migrate existing tests and remove jest-fetch-mock.

Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation Brief

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

wheresrhys commented 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.

felixarntz commented 4 years ago

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 ✅

eugene-manuilov commented 4 years ago

QA :heavy_check_mark: