I can't figure out why my jest mocks aren't working consistently. I understand the behavior about mocks being lifted, but I don't see how/why that would break my code in this case.
The following works
import fetchMock from 'jest-fetch-mock';
fetchMock.enableMocks();
fetchMock.dontMock();
fetchMock.doMockIf('...', async () => {
return JSON.stringify([
{
AccountName: '...'
}
]);
});
describe('....', () => {
let sut = ....
and my fetch call is mocked
If I do the following, my mock fetch is never called
import './mocks';
describe('....', () => {
let sut = ....
I can't figure out why my jest mocks aren't working consistently. I understand the behavior about mocks being lifted, but I don't see how/why that would break my code in this case.
The following works
and my fetch call is mocked
If I do the following, my mock fetch is never called
mocks.ts:
Any ideas about what's going on here?
Thanks.