Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request mochajs#2560 from jeversmann/add/new-timeout-message
Browse files Browse the repository at this point in the history
Add a more clear timeout message. Closes mochajs#2294
  • Loading branch information
Munter committed Oct 29, 2016
2 parents f207156 + 0294762 commit f32b53d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/runnable.js
Expand Up @@ -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);
};
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions mocha.js
Expand Up @@ -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);
};
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f32b53d

Please sign in to comment.