Skip to content

armgit / mocha

Public Imported from GitHub
0

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

resolves #1300: passing 0 to timeout() will disable timeouts

Christopher Hiller4c0c47978acc
diff --git a/lib/runnable.js b/lib/runnable.js
index b0bb1a9b..26962935 100644
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -64,6 +64,7 @@ Runnable.prototype.__proto__ = EventEmitter.prototype;
Runnable.prototype.timeout = function(ms){
if (0 == arguments.length) return this._timeout;
+ if (ms === 0) this._enableTimeouts = false;
if ('string' == typeof ms) ms = milliseconds(ms);
debug('timeout %d', ms);
this._timeout = ms;
diff --git a/test/acceptance/timeout.js b/test/acceptance/timeout.js
index 0042f831..3e865f97 100644
--- a/test/acceptance/timeout.js
+++ b/test/acceptance/timeout.js
@@ -25,5 +25,11 @@ describe('timeouts', function(){
this.timeout(1);
setTimeout(done, 2);
});
+
+ it('should work with timeout(0)', function(done) {
+ this.timeout(0);
+ setTimeout(done, 1);
+ })
});
+
})