Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Saving timer references to avoid Sinon interfering.

domenic4c160d7326eb
diff --git a/bin/_mocha b/bin/_mocha
index f9ef9ab1..a0545637 100755
--- a/bin/_mocha
+++ b/bin/_mocha
@@ -20,6 +20,16 @@ var program = require('commander')
, join = path.join
, cwd = process.cwd();
+/**
+ * Save timer references to avoid Sinon interfering (see GH-237).
+ */
+
+var Date = global.Date
+ , setTimeout = global.setTimeout
+ , setInterval = global.setInterval
+ , clearTimeout = global.clearTimeout
+ , clearInterval = global.clearInterval;
+
/**
* Files.
*/
diff --git a/lib/reporters/base.js b/lib/reporters/base.js
index 2fe294a9..b61baeba 100644
--- a/lib/reporters/base.js
+++ b/lib/reporters/base.js
@@ -6,6 +6,16 @@
var tty = require('tty')
, diff = require('diff');
+/**
+ * Save timer references to avoid Sinon interfering (see GH-237).
+ */
+
+var Date = global.Date
+ , setTimeout = global.setTimeout
+ , setInterval = global.setInterval
+ , clearTimeout = global.clearTimeout
+ , clearInterval = global.clearInterval;
+
/**
* Check if both stdio streams are associated with a tty.
*/
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index b7ebcbfd..7b3a1c2c 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -8,6 +8,16 @@ var Base = require('./base')
, Progress = require('../browser/progress')
, escape = utils.escape;
+/**
+ * Save timer references to avoid Sinon interfering (see GH-237).
+ */
+
+var Date = global.Date
+ , setTimeout = global.setTimeout
+ , setInterval = global.setInterval
+ , clearTimeout = global.clearTimeout
+ , clearInterval = global.clearInterval;
+
/**
* Expose `Doc`.
*/
diff --git a/lib/reporters/xunit.js b/lib/reporters/xunit.js
index 63bcbd4d..868c1477 100644
--- a/lib/reporters/xunit.js
+++ b/lib/reporters/xunit.js
@@ -7,6 +7,16 @@ var Base = require('./base')
, utils = require('../utils')
, escape = utils.escape;
+/**
+ * Save timer references to avoid Sinon interfering (see GH-237).
+ */
+
+var Date = global.Date
+ , setTimeout = global.setTimeout
+ , setInterval = global.setInterval
+ , clearTimeout = global.clearTimeout
+ , clearInterval = global.clearInterval;
+
/**
* Expose `XUnit`.
*/
diff --git a/lib/runnable.js b/lib/runnable.js
index beb46917..bcc72a9c 100644
--- a/lib/runnable.js
+++ b/lib/runnable.js
@@ -6,6 +6,16 @@
var EventEmitter = require('events').EventEmitter
, debug = require('debug')('runnable');
+/**
+ * Save timer references to avoid Sinon interfering (see GH-237).
+ */
+
+var Date = global.Date
+ , setTimeout = global.setTimeout
+ , setInterval = global.setInterval
+ , clearTimeout = global.clearTimeout
+ , clearInterval = global.clearInterval;
+
/**
* Expose `Runnable`.
*/