☕️ Classic, reliable, trusted test framework for Node.js and the browser
Fixed hook timeouts
TJ Holowaychuk667379c39f5c
diff --git a/lib/runner.js b/lib/runner.jsindex 3aebd256..1d9546db 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -117,7 +117,9 @@ Runner.prototype.failHook = function(hook, err){Runner.prototype.hook = function(name, fn){var suite = this.suite- , callbacks = suite[name + 'Callbacks'];+ , callbacks = suite[name + 'Callbacks']+ , ms = suite._timeout+ , timer;function next(i) {var callback = callbacks[i];@@ -125,9 +127,15 @@ Runner.prototype.hook = function(name, fn){// asyncif (1 == callback.length) {+ // timeout+ timer = setTimeout(function(){+ fn(new Error('timeout of ' + ms + 'ms exceeded'));+ }, ms);+// asynctry {callback(function(err){+ clearTimeout(timer);if (err) return fn(err);next(++i);});diff --git a/test/timeout.js b/test/timeout.jsindex 11481600..70b506f0 100644--- a/test/timeout.js+++ b/test/timeout.js@@ -1,8 +1,14 @@describe('timeouts', function(){+ beforeEach(function(done){+ // uncomment+ // setTimeout(done, 3000);+ done();+ })+it('should error on timeout', function(done){// uncomment// setTimeout(done, 3000);done();- });+ })});\ No newline at end of file