You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But, there's a trap! If that expectation does not pass, we never hit the done callback and the assertion error will be swallowed!
The only appropriate way to use done callbacks in tests are:
// Promises. This is what we should be doing.it('test stuff',()=>{unit.doSomething();returnnewPromise(resolve=>{setTimeout(resolve,0));}).then(()=>{expect(somethingDoneAsync).equal('value');});});
// Node style. But why would you do this?setTimeout(()=>{leterror=null;try{expect(somethingDoneAsync).equal('value');}catch(e){error=e;}done(error);},0);
The text was updated successfully, but these errors were encountered:
Imagine code like this:
But, there's a trap! If that expectation does not pass, we never hit the
done
callback and the assertion error will be swallowed!The only appropriate way to use
done
callbacks in tests are:The text was updated successfully, but these errors were encountered: