Home > Enterprise >  How to force a return value from a mocked non-exported function using sinon or proxyquire or rewire?
How to force a return value from a mocked non-exported function using sinon or proxyquire or rewire?

Time:02-28

I am just getting started unit testing nodejs. I have been using mocha, chai and sinon.

I hit a snag when I wanted to test a function which is not exported. proxyquire looks good, as does rewire.

There are lots of tutorials, but they tend to be simplistic. E.g

// Software under test
function saySecret() {      // this function is *not* exported
  return '           
  • Related