0

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?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122

0 Answers0