Skip to content

Commit

Permalink
[Robustness] be robust against the global setTimeout changing.
Browse files Browse the repository at this point in the history
Fixes #292.
  • Loading branch information
ljharb committed Jun 8, 2016
1 parent 7ea6373 commit f2351ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var nextTick = typeof setImmediate !== 'undefined'
? setImmediate
: process.nextTick
;
var safeSetTimeout = setTimeout;

inherits(Test, EventEmitter);

Expand Down Expand Up @@ -119,7 +120,7 @@ Test.prototype.plan = function (n) {
Test.prototype.timeoutAfter = function(ms) {
if (!ms) throw new Error('timeoutAfter requires a timespan');
var self = this;
var timeout = setTimeout(function() {
var timeout = safeSetTimeout(function() {
self.fail('test timed out after ' + ms + 'ms');
self.end();
}, ms);
Expand Down

0 comments on commit f2351ca

Please sign in to comment.