Open edouard-lopez opened 5 years ago
No that's definitely not expected behaviour. The only thing I can think of without investigating is that you are only calling fetch once. But you are also showing the logs from your calls
Below is how I setup jest-fetch-mock
in src/setupTests.js
import fetch from 'jest-fetch-mock';
jest.setMock('isomorphic-fetch', fetch);
It's also imported at the top of my test file src/pbx/outcalls/__tests__/services.test.js
and reset mock before each tests:
import fetch from 'jest-fetch-mock';
import * as Outcall from '../services';
describe('Outcall Service', () => {
beforeEach(() => {
localStorage.setItem('connectedInstance', JSON.stringify({ connectedInstance: 'fake' }));
fetch.resetMocks();
});
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
andtoHaveBeenCalledTimes
:Error
Console.log
Mock respond correctly to the calls
Test
Code
Is it the expected behavoir?