Opera reports 1 failure when actually everything passed #243

satazor opened this Issue Jan 30, 2012 · 15 comments


None yet
8 participants

satazor commented Jan 30, 2012

I have a test case that has exactly 41 tests and while testing in node or Chrome/Safari/Firefox everything works great except in Opera.

It says:

passes: 41
failures: 1
duration: 0.21s

In chrome (for example) it says:

passes: 41
failures: 0
duration: 0.31s

This can be reproduced by checking out https://github.com/TrinityJS/Classify and opening test/Classify.all.html in Opera.


paulmillr commented Jan 30, 2012

+1, same issue in paulmillr/es6-shim

zikes commented Jan 30, 2012

+1, same issue in Chrome on one of my projects. I find it occurs after the very first test operation, incrementing both the passes and failures by one, no matter what the first test operation is.


tj commented Feb 15, 2012

hmm interesting I'll take a look


tj commented Feb 15, 2012

k yeah i get the same, nice that opera finally has a decent console


tj commented Feb 15, 2012

apparently we have a "stats" global that's not being reported, it's getting the "test end" event but .passed is true even though it failed, some state issue


satazor commented Apr 11, 2012

Now in opera an error is thrown:

global leak detected: stats

Thats exactly what @visionmedia said, mocha has a global leak :p


tj commented Jun 17, 2012

This issue has been inactive for over 1 month so I'm closing it. If you think it's still an issue re-open. - tjbot

@tj tj closed this Jun 17, 2012

satazor commented Jul 8, 2012

@visionmedia the problem still persists.. but I don't have permission to reopen..

@tj tj reopened this Jul 9, 2012

I have the same issue and I temporarily resolved using this code:

var globals = [];
if (navigator.userAgent.indexOf('Opera') !== -1) {
    globals.push('stats', 'report');


Still this should be fixed in mocha itself.

satazor commented Aug 29, 2012



Krinkle commented Nov 2, 2012

From chaplinjs/chaplin#147:

I get strange global leaks detected: stats, report errors in Opera. We’re definitely not creating these vars, this must be an error in Mocha.

I just got the same. Working fine in Firefox 15 and Chrome 22, but causing these global detected failures in the default Mocha test suite, both in Opera 12 and IE9.

So I booted up BrowserStack and looked up in the console what these variables where actually set to:
Mocha Standard tests fail in Opera and IE

Turns out these are the DOM elements Mocha creates during the test. And guess what, both Opera and IE are famous for exposing global variables for every element ID.

The way we fixed this in QUnit (jquery/qunit#212) is by prefixing our IDs with "qunit-" (never a bad habit, but with "mocha-", of course). And filtering these out in the global check (jquery/qunit@1e21c01e).


tj commented Nov 2, 2012

hahaha yikes, that's messed, thanks for looking into it


Krinkle commented Nov 2, 2012

I'm preparing a pull request now.

@tj tj closed this in 4837a93 Nov 2, 2012

tj added a commit that referenced this issue Nov 2, 2012

Merge pull request #635 from Krinkle/issue-243-global
Issue #243 - Fix DOM globals in Opera/IE

tobsn commented Nov 7, 2012

is that already updated on npm? i just installed mocha and im still getting global leaks detected: stats, report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment