jefflau / jest-fetch-mock

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

jest.setMock not needed in enableMocks #139

Open Chocrates opened 4 years ago

Chocrates commented 4 years ago

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

jefflau commented 4 years ago

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