I am new to unit testing in Node. I am using sinon asserts for chai, mocha, and proxyquire.
In the function below, when I assert if fetch ran.... I get positives for both fetch.should.not.have.been.called and fetch.should.have.been.called so I know I am getting false positives.
function normalAlert() {
...
fetch(request)
.then(toJSON)
.then((e) => {
})
.catch((e) => {
console.log('error ' + e);
});
}
it('should run fetch', ()=> {
var fetch = sinon.stub();
var alerts = proxy('../alerts', {'fetch': fetch});
alerts.normalAlert();
fetch.should.have.been.called
});
via dman
No comments:
Post a Comment