I need to mock the response of a function being called inside an arrow function to test every line of the code. I have the following code:
function foo() {
return 'apiCall'
}
const handle = async () => {
const a = await foo()
if (a == 'apiCall') {
//do something
} else {
//do other thing
}
}
module.exports = {
foo,
handle
}
I can use the following dev dependencies: chai, chai-http, node-mocks-http, proxyquire, sinon. How can I mock the response of foo()
to test every line of handle()
function?