jest-fetch-mock icon indicating copy to clipboard operation
jest-fetch-mock copied to clipboard

jest.setMock not needed in enableMocks

Open Chocrates opened this issue 5 years ago • 1 comments

I believe the jest.setMock(..) call on this line is not needed: https://github.com/jefflau/jest-fetch-mock/blob/master/src/index.js#L240

Due to the way jest mocking works (which is super unclear to me) we can't setup a mock from within a module. The fetch mock still works because fetch isn't require'd and instead global.
I was able to remove the setMock statement in a test setup and fill it with garbage, and the sample tests still work.

I definitely could be mistaken, like I said I basically have no idea how jest mocks are scoped

Chocrates avatar Dec 23 '19 21:12 Chocrates

@yinzara Can you take a look at this if you have time?

jefflau avatar Jan 14 '20 07:01 jefflau