When running the tests on a JavaScript lab, you might see the following error message:

1)  "before all" hook:
   Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

For each lab, the JavaScript test framework is allotted a certain amount of time in which to run the tests. This error occurs when the tests do not finish running within that amount of time.

This error does not indicate that anything is wrong with your code.

To fix this, follow these steps:

  1. Open the package.json  file in the directory for your lab.
  2. Locate the "scripts"  key, and the "test"  key within "scripts" 
  3. After mocha , add --timeout 5000  so that the key looks like this:  "scripts": { "test": "mocha --timeout 5000 -R mocha-multi --reporter-options nyan=-,json=.results.json" }

If you still receive this error, increase the number in step 3 by 5000 (to 10000) and run the tests again. Repeat this step until this error no longer occurs.

Did this answer your question?