I have two tests that look something like:
import someThing from '../someThing';
jest.mock('../someThing');
describe('group', () => {
it('test #1', async () => {
someThing.someFunction.mockImplementation(() => 123);
});
it('test #2', async () => {
someThing.someFunction.mockImplementation(() => 456);
});
});
I'm seeing an issue where it appears the mockImplementation from the first test is being called in the second test. If I disable test #1 test# 2 works as expected. (My actual code is more complicated than this).
The reason I need a separate mock for both is that one is supposed to return a failure result and one is supposed to return a success one given the same input.
From what I understand, JEST runs all test in parallel so I'm assuming what's happening is that the mockImplementation is being modified by both tests at the same time as it's the same import.