Why is this test failing, saying that the onSuccess
spy was never called?
it('should correctly call the success callback',function(done)
{
const callbacks={
onSuccess:function()
{
console.log('OK');
done();
},
onError:function()
{
console.log('ERR');
done();
}
};
spyOn(callbacks,'onSuccess').and.callThrough();
spyOn(callbacks,'onError').and.callThrough();
doSomethingAsync(callbacks.onSuccess,callbacks.onError);
expect(callbacks.onSuccess).toHaveBeenCalled();
expect(callbacks.onError).not.toHaveBeenCalled();
});
When running the test, I get an error saying Expected spy onSuccess to have been called.
.
Right above that, there's a console log saying "OK", meaning that the spy was called and that it called through.
Aucun commentaire:
Enregistrer un commentaire