Skip to content

Commit

Permalink
resolves mochajs#1300: passing 0 to timeout() will disable timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Hiller authored and tandrewnichols committed Dec 15, 2014
1 parent 6958ce3 commit 35e296c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/runnable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions test/acceptance/timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
});

})

0 comments on commit 35e296c

Please sign in to comment.