How to stop Global Failures in qUnit?

I'm new to qunit, and am attempting to integrate it with an existing environment.

One of the issues I get on pages that utilize jQuery is this:

global failure (1, 0, 1)Rerun6 ms
Uncaught ReferenceError: $ is not defined

I think this is because I'm not calling the jquery library in the qunit HTML. Is it possible to set a parameter to ignore globals like this? I am trying to make the HTML as flexible as possible, and as many editors have different dependencies, I only want qunit to test the functions I specifically give it to test.


I'm stumped at the same error, however without using jQuery. The part of QUnit that is responsible for propagating the error is the window.onerror callback function, which, among other things, check whether the QUnit.config.current.ignoreGlobalErrors configuration value is set.

QUnit configuration values are described in the QUnit.config documentation. Unfortunately, the current property of config object is not described, but from looking at the source, the ignoreGlobalErrors configuration property defines whether global errors are reported or not. A test run with the following lines commented out runs fine:

QUnit.test( "global failure", extend( function() {
    QUnit.pushFailure( error, filePath + ":" + linerNr );
}, { validTest: validTest } ) );

I realize that this is just a hack, but if you're looking for a quick'n'dirty way to silence QUnit, this will work.

I had this problem using Chrome and found that it was one of my chrome extensions that was throwing an error and causing problems with QUnit. Try disabling extensions and restarting the browser.

for me it was simply a QUnit problem. just changed lower version of qunit, no error..

From Qunit 2.x upgrade guide I can read there has been a change in using Qunit object, when using 1.x it works like this:

test( "global failure", extend( function() {
    QUnit.pushFailure( error, filePath + ":" + linerNr );
    }, { validTest: validTest } ) );

On the other hand when using 2.x:

Qunit.test( "global failure", extend( function() {
    QUnit.pushFailure( error, filePath + ":" + linerNr );
    }, { validTest: validTest } ) );

should work instead. :-)

Need Your Help

Collection views - receiving images from different folders - how?

ios uitabbarcontroller uicollectionview

I'm creating a tabbar app with two collection views. I successfully have 2 tab bars working with a collection view but they're both receiving data from the same images folder - thumbs & full. S...

UISplitViewController stops auto-rotating after trying to use the UINavigationController inside of it

cocoa-touch ios uinavigationcontroller rotation uisplitviewcontroller

I've been having a bit of trouble with a UISplitViewController in my iPad app. I am attempting to make a simple navigation tree using the UINavigationController inside of the UISplitView. I have us...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.