Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Added ability to disable timeouts: `timeout(false)`

Guillermo Rauchad110e041cad
diff --git a/lib/runnable.js b/lib/runnable.js
index e94414df..972c1d78 100644
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -82,9 +82,11 @@ Runnable.prototype.resetTimeout = function(){
var self = this
, ms = this.timeout();
this.clearTimeout();
- this.timer = setTimeout(function(){
- self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
- }, ms);
+ if (false !== ms) {
+ this.timer = setTimeout(function(){
+ self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
+ }, ms);
+ }
};
/**
@@ -103,9 +105,11 @@ Runnable.prototype.run = function(fn){
// timeout
if (this.async) {
- this.timer = setTimeout(function(){
- done(new Error('timeout of ' + ms + 'ms exceeded'));
- }, ms);
+ if (false !== ms) {
+ this.timer = setTimeout(function(){
+ done(new Error('timeout of ' + ms + 'ms exceeded'));
+ }, ms);
+ }
}
// called multiple times