Monday 8 May 2017

Sinon Spy Reporting False Negative On Exported Function

I have a spy on normalAlert function(exported from alerts). It is so I can assert it has been called.

However, the spy does not report the function has been called even though it has in the test. I console.log() out inside of the normalAlert function in the source code to make sure it was being called.

Why is my spy falsely reporting normalAlert has not been called?

var index = require('../index');
var alerts = require('../alerts');
var normalAlertSpy = sinon.spy(alerts, 'normalAlert');
index.init();
normalAlertSpy.should.have.been.called.twice;


  1 failing

  1) When rain is in the forcast should run fetch:
     AssertionError: expected normalAlert to have been called at least once, but it was never called
      at Context.it (test/index.js:39:36)



via dman

No comments:

Post a Comment