My codes are:
utils.js:
exports.a = function a(){
b()
}
function b() {}
exports.b = function b(){
}
utils.test.js:
var utils = require('./utils')
test('b called by a', () => {
u.b = jest.fn()
utils.a()
expect(utils.b).toHaveBeenCalled()
})
When run unit test,it failed with:
Expected number of calls: >= 1
Received number of calls: 0
How to test it in a correct way?