question with mocha test , how can i detect `iterate` was done ?
tommyZZM opened this issue · 2 comments
Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
how can i detect iterate
was done ?
Hi, @tommyZZM.
The error message means that the test took too much time to run, so mocha cancelled it. You can simply solve the problem by increasing the timeout: Run mocha with --timeout 5000
to increase the timeout to 5000ms (5s), for instance.
Maybe the code you are testing takes quite long to run. You can also decrease the iteration count (the first parameter you pass to iterate
). If you iterate 100 times like in the sample then try to decrease it to 30, for instance.
I will add a timeout section to the README for future use :)
Just added a "You might want to know" section to the README, also containing tips how to deal with timeout errors like I wrote to you here.
If you find some time, tell me if that helps 😉