Skip to content

Commit f2351ca

Browse files
committed
[Robustness] be robust against the global setTimeout changing.
Fixes #292.
1 parent 7ea6373 commit f2351ca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var nextTick = typeof setImmediate !== 'undefined'
1212
? setImmediate
1313
: process.nextTick
1414
;
15+
var safeSetTimeout = setTimeout;
1516

1617
inherits(Test, EventEmitter);
1718

@@ -119,7 +120,7 @@ Test.prototype.plan = function (n) {
119120
Test.prototype.timeoutAfter = function(ms) {
120121
if (!ms) throw new Error('timeoutAfter requires a timespan');
121122
var self = this;
122-
var timeout = setTimeout(function() {
123+
var timeout = safeSetTimeout(function() {
123124
self.fail('test timed out after ' + ms + 'ms');
124125
self.end();
125126
}, ms);

0 commit comments

Comments
 (0)