Closed joshuajaco closed 4 years ago
I started to write another comment, however I think your concerns are valid. A library that does not have any form of exported contents that only supplies types and a global scope can be confusing and difficult for others to understand. There is also no way with the current library to say "Only mock for this one test".
The change you've suggested isn't actually enough to achieve what needs to be done to fix the library. I'm going to open a new PR with additional changes that should alleviate this confusion.
Moved to PR#148
This PR was just meant to type the already existing default export, because we are currently globally mocking fetch with:
require('jest-fetch-mock').enableMocks();
and then using it in our tests with:
const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;
customGlobal.fetch.mockResponse('{}');
Which isn't ideal. I applied the changes of this PR locally and it seemed to work in our setup. However I can see a "Only mock for this one test" feature being useful as well. Thanks for the help 👍
Closes https://github.com/jefflau/jest-fetch-mock/issues/146