I'm trying to spy on a function that's called by another function, both of which reside in an external file and imported.
Funcs.spec.js:
import * as Funcs from './Funcs'
describe('funcA', () => {
it('calls funcB', () => {
jest.spyOn(Funcs, 'funcB')
Funcs.funcA()
expect(Funcs.funcB).toHaveBeenCalled()
}
}
Funcs.js:
export const funcA = () => {
funcB()
}
export const funcB = () => {}
For some reason the spy is not respected in scope of Funcs.js. What can I do to spy on funcB so I know funcA has called it?