Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Never time out after calling enableTimeouts(false)

Rob Wu31a125351aa7
diff --git a/lib/runnable.js b/lib/runnable.js
index 26962935..94090071 100644
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -154,6 +154,7 @@ Runnable.prototype.resetTimeout = function(){
if (!this._enableTimeouts) return;
this.clearTimeout();
this.timer = setTimeout(function(){
+ if (!self._enableTimeouts) return;
self.callback(new Error('timeout of ' + ms + 'ms exceeded'));
self.timedOut = true;
}, ms);
diff --git a/test/acceptance/timeout.js b/test/acceptance/timeout.js
index 7334b72d..a12f2fb1 100644
--- a/test/acceptance/timeout.js
+++ b/test/acceptance/timeout.js
@@ -51,6 +51,16 @@ describe('timeouts', function(){
})
})
+ describe('using enableTimeouts(false)', function() {
+ this.timeout(4);
+
+ it('should suppress timeout(4)', function(done) {
+ // The test is in the before() call.
+ this.enableTimeouts(false);
+ setTimeout(done, 50);
+ })
+ })
+
describe('suite-level', function() {
this.timeout(0);