☕️ Classic, reliable, trusted test framework for Node.js and the browser
Remove invalid optimization in checkGlobals().
Noshir Patel1d7c828049a5
diff --git a/lib/runner.js b/lib/runner.jsindex f2420f2e..1e73be72 100644--- a/lib/runner.js+++ b/lib/runner.js@@ -168,10 +168,6 @@ Runner.prototype.checkGlobals = function(test){ok = ok.concat(test._allowedGlobals || []);}- // check length - 2 ('errno' and 'location' globals)- if (isNode && 1 == ok.length - globals.length) return;- else if (2 == ok.length - globals.length) return;-if(this.prevGlobalsLength == globals.length) return;this.prevGlobalsLength = globals.length;diff --git a/test/runner.js b/test/runner.jsindex 0d6d2029..5a758991 100644--- a/test/runner.js+++ b/test/runner.js@@ -97,6 +97,21 @@ describe('Runner', function(){runner.checkGlobals('im a test');})+ it('should emit "fail" when a single new disallowed global is introduced after a single extra global is allowed', function(done) {+ var doneCalled = false;+ runner.globals('good');+ global.bad = 1;+ runner.on('fail', function(test, err) {+ delete global.bad;+ done();+ doneCalled = true;+ });+ runner.checkGlobals('test');+ if (!doneCalled) {+ done(Error("Expected test failure did not occur."));+ }+ });+it ('should not fail when a new common global is introduced', function(){// verify that the prop isn't enumerabledelete global.XMLHttpRequest;