From b7cbea2097056f31e1cf664355c4f91fcde68cc0 Mon Sep 17 00:00:00 2001 From: Josh Eversmann Date: Fri, 28 Oct 2016 16:27:11 -0500 Subject: [PATCH] add a more clear timeout message. Closes #2294 --- lib/runnable.js | 6 ++++-- mocha.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/runnable.js b/lib/runnable.js index 3edd9abd3e..6825fb1876 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 16d5619e27..26ab122c44 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); }