Skip to content

armgit / mocha

Public Imported from GitHub
0

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

fix check-leaks to catch a leak whose name begins with 'd'

Mick Brooksa419b9f9f84f
diff --git a/lib/runner.js b/lib/runner.js
index ba4d7df9..9adfdb43 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -838,7 +838,7 @@ Runner.prototype.abort = function() {
function filterLeaks(ok, globals) {
return filter(globals, function(key) {
// Firefox and Chrome exposes iframes as index inside the window object
- if (/^d+/.test(key)) {
+ if (/^\d+/.test(key)) {
return false;
}
diff --git a/test/runner.js b/test/runner.js
index 7673a838..a0643397 100644
--- a/test/runner.js
+++ b/test/runner.js
@@ -179,6 +179,15 @@ describe('Runner', function(){
});
runner.checkGlobals(test);
})
+
+ it('should emit "fail" when a global beginning with d is introduced', function(done) {
+ global.derp = 'bar';
+ runner.on('fail', function(test, err){
+ delete global.derp;
+ done();
+ });
+ runner.checkGlobals('im a test');
+ });
})
describe('.hook(name, fn)', function(){