Relative Content

Tag Archive for typescriptfetch-apihttpresponsets-jestjest-fetch-mock

Mocking fetch return response using Jest in Typescript

I have a function that calls fetch() and handles different cases of its response data.
When trying to mock the global fetch function using Jest I am having trouble with the Response type.
I only need the response.ok, and response.json properties.
How can I set the return data of fetch without having to write out all of the required properties?