Since you want to mock out foo at every test level, it makes more sense to keep bar mocked globally and use beforeEach() or afterEach() to reset the mocked function before or after each test runs.

import {foo} from 'bar';


afterEach(() => {

test('test', () => {

You'll want to use .mockReset() to remove mocked implementations and return values from foo; alternatively, .mockClear() can be used if the implementation and return value for foo remains the same for each test. Read more on the difference here.

Related Query

More Query from same tag