According to Mocha documentation, "Mocha tests run serially" which means in the order they are defined.
My question is: what makes async (with done callback) tests different than sync?
You tell Mocha that a test is asynchronous by passing to the it
call a function that takes an argument (traditionally named done
). Mocha will then call this function with a first argument which is a callback that you must call to tell Mocha the test is over.
The only difference between an asynchronous test and a synchronous one is that for an asynchronous test Mocha will wait for the done
callback to be called before moving on to the next test. If the test is deemed to be synchronous, then Mocha will move on to the next test as soon as the function you passed to it
returns. If Mocha were to do this with asynchronous tests too then it would not be able to associate unhandled exceptions with the appropriate test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With