I am testing a method A which is calling another method B with different arguments based on conditions. So I would want to spy on B so that I can check whether its called. But the spy is never getting called.
import parent from '../something.js'
describe('Testing A', () => {
it('should make proper calls to B', () => {
var spy = sinon.spy(parent, 'B')
parent.A()
expect(spy.calledOnce).to.be.true
})
})
and the test function A would just be
export const A = () => {
B()
}
Seems like in test, spy version of B is never called because A calls B directly. How can I make the test function of A to call the Sinon version of B?