lundi 15 juillet 2019

Sinon .callsFake() is not mocking the return of the function

I have the following code in my test file:

    const stub1 = sinon.stub('../path/to/module', '_myFunc')
    stub1.callsFake( function()  { console.log("223344") }
    )

Inside a beforeEach in Mocha, but when _myFunc gets called, it is not executing the console.log.

_myFunc is exported like this:

module.exports = {
  _myFunc
}

What am i doing wrong?

Aucun commentaire:

Enregistrer un commentaire