In my code, there is an asynchronous function that doesn't return. When it gets called, it just runs some stuff in the background.
I want to test that a second function is getting called inside this function.
The problem is, I need to wait for asyncFunction
to be complete before I can perform the check if someOtherFunctionCall
was called.
Is there any way I can check the status of the stack to see that no function is currently running?
function asyncFunction(){
setTimeout(() => {
someOtherFunctionCall();
console.log("Time Passed");
}, 3000)
}
it('the test', () => {
spyOn(someOtherFunctionCall);
asyncFunction();
// Wait for stack to be clear ??
expect(asyncFunction).to.have.been.called;
});
Aucun commentaire:
Enregistrer un commentaire