I am reading some tutorials on promise tests in mocha. There is a piece of codes:
before(function(done) {
return Promise.resolve(save(article)).then(functi
In this particular case there is no functional difference. The callback, often called done
, was introduced to handle asynchronous tests when using callbacks. Returning a Promise
is sufficient, but note that you cannot define the done
callback, because the test suite will wait until it's called. Use done
when you can't easily return a Promise
. In your case the second test will be infinite, because you define done
, which you never actually call.