Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

add a more clear timeout message. Closes #2294

Josh Eversmannb7cbea209705
diff --git a/lib/runnable.js b/lib/runnable.js
index 3edd9abd..6825fb18 100644
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -229,7 +229,8 @@ Runnable.prototype.resetTimeout = function () {
if (!self._enableTimeouts) {
return;
}
- self.callback(new Error('timeout of ' + ms + 'ms exceeded. Ensure the done() callback is being called in this test.'));
+ self.callback(new Error('timeout! Test didn\'t complete within ' + ms +
+ '. For async tests, make sure you are calling \'done\' or that the returned Promise eventually resolves.'));
self.timedOut = true;
}, ms);
};
@@ -288,7 +289,8 @@ Runnable.prototype.run = function (fn) {
self.duration = new Date() - start;
finished = true;
if (!err && self.duration > ms && self._enableTimeouts) {
- err = new Error('timeout of ' + ms + 'ms exceeded. Ensure the done() callback is being called in this test.');
+ err = new Error('timeout! Test didn\'t complete within ' + ms +
+ '. For async tests, make sure you are calling \'done\' or that the returned Promise eventually resolves.');
}
fn(err);
}
diff --git a/mocha.js b/mocha.js
index 16d5619e..26ab122c 100644
--- a/mocha.js
+++ b/mocha.js
@@ -4331,7 +4331,8 @@ Runnable.prototype.resetTimeout = function () {
if (!self._enableTimeouts) {
return;
}
- self.callback(new Error('timeout of ' + ms + 'ms exceeded. Ensure the done() callback is being called in this test.'));
+ self.callback(new Error('timeout! Test didn\'t complete within ' + ms +
+ '. For async tests, make sure you are calling \'done\' or that the returned Promise eventually resolves.'));
self.timedOut = true;
}, ms);
};
@@ -4390,7 +4391,8 @@ Runnable.prototype.run = function (fn) {
self.duration = new Date() - start;
finished = true;
if (!err && self.duration > ms && self._enableTimeouts) {
- err = new Error('timeout of ' + ms + 'ms exceeded. Ensure the done() callback is being called in this test.');
+ err = new Error('timeout! Test didn\'t complete within ' + ms +
+ '. For async tests, make sure you are calling \'done\' or that the returned Promise eventually resolves.');
}
fn(err);
}