Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit f19c213

Browse files
authored
Merge pull request mochajs#2181 from JustATrick/fix-check-leaks
fix check-leaks to catch a leak whose name begins with 'd'
2 parents 1e1b4db + a419b9f commit f19c213

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/runner.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ function hasOnly(suite) {
892892
function filterLeaks(ok, globals) {
893893
return filter(globals, function(key) {
894894
// Firefox and Chrome exposes iframes as index inside the window object
895-
if (/^d+/.test(key)) {
895+
if (/^\d+/.test(key)) {
896896
return false;
897897
}
898898

test/runner.js

+9
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ describe('Runner', function(){
179179
});
180180
runner.checkGlobals(test);
181181
})
182+
183+
it('should emit "fail" when a global beginning with d is introduced', function(done) {
184+
global.derp = 'bar';
185+
runner.on('fail', function(test, err){
186+
delete global.derp;
187+
done();
188+
});
189+
runner.checkGlobals('im a test');
190+
});
182191
})
183192

184193
describe('.hook(name, fn)', function(){

0 commit comments

Comments
 (0)