aboutsummaryrefslogtreecommitdiffstats
path: root/test/data/testinit.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/data/testinit.js')
-rw-r--r--test/data/testinit.js52
1 files changed, 18 insertions, 34 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js
index 23cea8a40..a04bc49c7 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -1,21 +1,15 @@
/* eslint no-multi-str: "off" */
"use strict";
-var FILEPATH = "/test/data/testinit.js",
- activeScript = [].slice.call( document.getElementsByTagName( "script" ), -1 )[ 0 ],
- parentUrl = activeScript && activeScript.src ?
- activeScript.src.replace( /[?#].*/, "" ) + FILEPATH.replace( /[^/]+/g, ".." ) + "/" :
- "../",
+var parentUrl = window.location.protocol + "//" + window.location.host,
// baseURL is intentionally set to "data/" instead of "".
// This is not just for convenience (since most files are in data/)
// but also to ensure that urls without prefix fail.
- // Otherwise it's easy to write tests that pass on test/index.html
- // but fail in Karma runner (where the baseURL is different).
- baseURL = parentUrl + "test/data/",
+ baseURL = parentUrl + "/test/data/",
supportjQuery = this.jQuery,
- // NOTE: keep it in sync with build/tasks/lib/slim-build-flags.js
+ // NOTE: keep it in sync with build/tasks/lib/slim-exclude.js
excludedFromSlim = [
"ajax",
"callbacks",
@@ -293,14 +287,9 @@ this.testIframe = function( title, fileName, func, wrapper, iframeStyles ) {
};
this.iframeCallback = undefined;
-// Tests are always loaded async
-// except when running tests in Karma (See Gruntfile)
-if ( !window.__karma__ ) {
- QUnit.config.autostart = false;
-}
+QUnit.config.autostart = false;
-// Leverage QUnit URL parsing to detect testSwarm environment and "basic" testing mode
-QUnit.isSwarm = ( QUnit.urlParams.swarmURL + "" ).indexOf( "http" ) === 0;
+// Leverage QUnit URL parsing to detect "basic" testing mode
QUnit.basicTests = ( QUnit.urlParams.module + "" ) === "basic";
// Support: IE 11+
@@ -366,10 +355,17 @@ this.loadTests = function() {
// QUnit.config is populated from QUnit.urlParams but only at the beginning
// of the test run. We need to read both.
var esmodules = QUnit.config.esmodules || QUnit.urlParams.esmodules;
+ var jsdom = QUnit.config.jsdom || QUnit.urlParams.jsdom;
+
+ if ( jsdom ) {
+
+ // JSDOM doesn't implement scrollTo
+ QUnit.config.scrolltop = false;
+ }
// Directly load tests that need evaluation before DOMContentLoaded.
- if ( !esmodules || document.readyState === "loading" ) {
- document.write( "<script src='" + parentUrl + "test/unit/ready.js'><\x2Fscript>" );
+ if ( !jsdom && ( !esmodules || document.readyState === "loading" ) ) {
+ document.write( "<script src='" + parentUrl + "/test/unit/ready.js'><\x2Fscript>" );
} else {
QUnit.module( "ready", function() {
QUnit.skip( "jQuery ready tests skipped in async mode", function() {} );
@@ -377,7 +373,7 @@ this.loadTests = function() {
}
// Get testSubproject from testrunner first
- require( [ parentUrl + "test/data/testrunner.js" ], function() {
+ require( [ parentUrl + "/test/data/testrunner.js" ], function() {
// Says whether jQuery positional selector extensions are supported.
// A full selector engine is required to support them as they need to
@@ -427,7 +423,7 @@ this.loadTests = function() {
if ( dep ) {
if ( !QUnit.basicTests || i === 1 ) {
- require( [ parentUrl + "test/" + dep ], loadDep );
+ require( [ parentUrl + "/test/" + dep ], loadDep );
// When running basic tests, replace other modules with dummies to avoid overloading
// impaired clients.
@@ -437,26 +433,14 @@ this.loadTests = function() {
}
} else {
- if ( window.__karma__ && window.__karma__.start ) {
- window.__karma__.start();
- } else {
- QUnit.load();
- }
+ QUnit.load();
/**
* Run in noConflict mode
*/
jQuery.noConflict();
- // Load the TestSwarm listener if swarmURL is in the address.
- if ( QUnit.isSwarm ) {
- require( [ "https://swarm.jquery.org/js/inject.js?" + ( new Date() ).getTime() ],
- function() {
- QUnit.start();
- } );
- } else {
- QUnit.start();
- }
+ QUnit.start();
}
} )();
} );