async test library load helper

This commit is contained in:
John Bender 2011-12-20 15:01:28 -08:00 committed by scottjehl
parent 66a818223a
commit 34dcbe2aa7

View file

@ -4,6 +4,34 @@
(function( $ ) {
$.testHelper = {
asyncLoad: function( opts ) {
var baseUrl = opts.baseUrl || "../../../js";
// stop qunit from running the tests until everything is in the page
QUnit.config.autostart = false;
// set the baseUrl to the js dir or the default
require({
baseUrl: baseUrl
});
// require the libs required to pass the test suite
require( opts.libs, function() {
// init the mobile library
require( ["jquery.mobile.init"], function() {
// reset the base dir to the current directory for including the test libs
require({
baseUrl: location.pathname
});
// after everything is inplace start the test suite
require( opts.testLibs, QUnit.start);
});
});
},
excludeFileProtocol: function(callback){
var message = "Tests require script reload and cannot be run via file: protocol";