☕️ Classic, reliable, trusted test framework for Node.js and the browser
added globalProps method.
Shawn Krisman003ea45587c2
diff --git a/lib/runner.js b/lib/runner.jsindex 34a503a7..0fecd354 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -94,6 +94,29 @@ Runner.prototype.grepTotal = function(suite) {return total;};+/**+ * Return a list of global properties.+ *+ * @return {Array} list of properties.+ * @api private+ */+Runner.prototype.globalProps = function() {+ var common = [+ 'setTimeout', 'clearTimeout', 'setInterval',+ 'clearInterval', 'Date', 'XMLHttpRequest'+ ];+ // these are only enumerable properties.+ var props = utils.keys(global);++ // now let's add some common non enumerable properties.+ for (var i = 0; i < common.length; i++) {+ if (props.indexOf(common[i]) === -1) {+ props.push(common[i]);+ }+ }+ return props;+};+/*** Allow the given `arr` of globals.*diff --git a/test/runner.js b/test/runner.jsindex c47f5bb1..e6e21d4e 100644--- a/test/runner.js+++ b/test/runner.js@@ -50,9 +50,21 @@ describe('Runner', function(){})})+ describe('.globalProps()', function(){+ it('should include common non enumerable globals', function() {+ var props = runner.globalProps();+ props.should.include('setTimeout');+ props.should.include('clearTimeout');+ props.should.include('setInterval');+ props.should.include('clearInterval');+ props.should.include('Date');+ props.should.include('XMLHttpRequest');+ });+ });+describe('.globals()', function(){it('should default to the known globals', function(){- runner.globals().length.should.be.above(10);+ runner.globals().length.should.be.above(16);})it('should white-list globals', function(){