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

Jest mock for fetch

Results 88 jest-fetch-mock issues
Sort by recently updated
recently updated
newest added

I'm trying to test a method to ensure all API calls are correctly done. However only the first one seem to be log and available in `fetch.mock.calls` and `toHaveBeenCalledTimes`: >...

Hi, I would like to know if there are is a way to implement POST or PUT methods using jest-fetch-mock, as far I see all the examples mentioned in the...

Currently we only have a few examples to help newbies use `jest-fetch-mock`. Although it's fairly self explanatory, I'd like to create a codesandbox with a simple React app (or other...

enhancement
help wanted

Hi! I have a problem using the fetch.resetMocks(); in the before each statement. ```js // app/utils/tests/request.test.js import request from '../request'; describe('request', () => { beforeEach(() => { fetch.resetMocks(); }); it('perform...

Is there a way to disable the mocking for specific tests and use the real fetch to hit a live server? Just for reference http://www.wheresrhys.co.uk/fetch-mock/#usageconfiguration has a `fallbackToNetwork` option.

In the examples I can see things like: expect(fetch.mock.calls.length).toEqual(1) expect(fetch.mock.calls[0][0]).toEqual('https://google.com') unfortunately this is not defined in the typescript files.

Is there a way to mock conditionally for cases with parallel requests? For example: ```js fetch.mockResponseOnce(...) // mocks first result, assuming "/blog/" fetch.mockResponseOnce(...) // mocks second result, assuming "/blog/post/" /*...

Hey, I'm trying to write a test for a network call that retries itself after it gets a response with an error code. The whole thing looks like this: ```...

With 2.0.0 release, we have functions that allow for an asynchronous mocks. I've added a resolve example, but we need to add a reject example

New PR https://github.com/jefflau/jest-fetch-mock/pull/75 adds async support. We should add an example to show how to use it. - Example of a timeout and reject representing the server being down -...

enhancement