☕️ Classic, reliable, trusted test framework for Node.js and the browser
Runnable.timeout(0) leaves Node running.
Michael Schoonmaker7c1139e8b47f
diff --git a/lib/runnable.js b/lib/runnable.jsindex c2406f75..ee533e9c 100644--- a/lib/runnable.js+++ b/lib/runnable.js@@ -132,15 +132,13 @@ Runnable.prototype.inspect = function(){Runnable.prototype.resetTimeout = function(){var self = this- , ms = this.timeout();+ , ms = this.timeout() || 1e9; // If the timeout is disabled, leave Node running.this.clearTimeout();- if (ms) {- this.timer = setTimeout(function(){- self.callback(new Error('timeout of ' + ms + 'ms exceeded'));- self.timedOut = true;- }, ms);- }+ this.timer = setTimeout(function(){+ self.callback(new Error('timeout of ' + ms + 'ms exceeded'));+ self.timedOut = true;+ }, ms);};/**diff --git a/test/runnable.js b/test/runnable.jsindex ff94bdeb..d21e80df 100644--- a/test/runnable.js+++ b/test/runnable.js@@ -211,6 +211,18 @@ describe('Runnable(title, fn)', function(){});})})++ it('should allow updating the timeout', function(done){+ var test = new Runnable('foo', function(done){+ this.timeout(10);+ });+ test.run(function(err){+ err.message.should.include('timeout');+ done();+ });+ })++ it('should allow a timeout of 0')})})