jefflau / jest-fetch-mock

Jest mock for fetch
MIT License
882 stars 116 forks source link

Fix global `resetMock: true` breaking fetch mocks #198

Closed ishmaelthedestroyer closed 2 years ago

ishmaelthedestroyer commented 3 years ago

Overview When developers set resetMock to true in their jest.config.js, it breaks the automocking. This can be seen by errors surfacing saying isMocking is not a function or its return value is not iterable or related.

This fixes that issue by resetting the isMocking and global fetch functions by resetting their values in a beforeEach call.

A PR has been opened in the original repo here: https://github.com/jefflau/jest-fetch-mock/pull/197

yinzara commented 2 years ago

lol sorry. you can't use a beforeEach in a helper library. That would break in so many ways I can't tell you. Someone simply having a test with a beforeEach outside of a describe block would break it.

Sorry man, definitely not going to accept this in any form.