Hi I want to spy the function as below, and because the function returns a promise, so I need to return the promise let other code continue running.
But it never passes the test, am I doing it wrong? how can I do this correctly? Thank you in advance.
Sorry I might not describe the problem clearly, another_fn will invoke object.method.origin_fn, and the orgin_fn returns a promise; I want to spy the origin_fn is get called. How can I do this?
let spy_fn = sinon.spy();
sinon.stub(object, 'method').returns({
origin_fn(args) {
spy_fn(args);
return Promise.resolve();
}
});
another_fn('test_args');
spy_fn.should.have.been.calledWith('test_args');