vendredi 25 décembre 2015

Angular + Mocha "timeout of 2000ms exceeded"

I'm getting the following error when running the entire suite of tests:

timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

I've been trying to figure out a way to fix this issue but no luck so far.

I found this super useful response here on SO: In mocha testing while calling asynchronous function how to avoid the timeout Error: timeout of 2000ms exceeded.

Where some of the suggestions are:

1. Calling done() at the end of the promises within the test

2. Use test stubs for network calls to make tests pass without having to rely on a functioning network

3. wrap your code with a try/catch and pass any exceptions to the done handler

I've done #1 and #2 (using Angular's $httpBackend for mocking http calls), but I'm still getting the timeout. However, #3 doesn't seem very pragmatic, since the suite of tests I'm dealing with is huge.

Does anyone have other suggestions? thanks!

Aucun commentaire:

Enregistrer un commentaire