Skip to content

armgit / mocha

Public Imported from GitHub
0

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

use setImmediate when available

Jesse Dailey73c49eb09b6b
diff --git a/lib/runner.js b/lib/runner.js
index 148950e0..45de65af 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -9,7 +9,12 @@ var EventEmitter = require('events').EventEmitter
, utils = require('./utils')
, filter = utils.filter
, keys = utils.keys
- , noop = function(){};
+ , noop = function(){}
+ , immediately = process.nextTick;
+
+if( global.setImmediate != undefined ) {
+ immediately = global.setImmediate;
+}
/**
* Non-enumerable globals.
@@ -242,7 +247,7 @@ Runner.prototype.hook = function(name, fn){
});
}
- process.nextTick(function(){
+ immediately(function(){
next(0);
});
};