diff options
author | Richard Gibson <richard.gibson@gmail.com> | 2018-09-07 10:14:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-07 10:14:01 -0400 |
commit | dfa92ccead70d7dd5735a36c6d0dd1af680271cd (patch) | |
tree | 95d7500d4ddcc944f3d388216c0c6bec211461d2 /test/jquery.js | |
parent | f997241f0011ed728be71002bc703c7a0d3f01e5 (diff) | |
download | jquery-dfa92ccead70d7dd5735a36c6d0dd1af680271cd.tar.gz jquery-dfa92ccead70d7dd5735a36c6d0dd1af680271cd.zip |
Tests: Allow Karma to load unminfied source
Closes gh-4128
Diffstat (limited to 'test/jquery.js')
-rw-r--r-- | test/jquery.js | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/test/jquery.js b/test/jquery.js index d8eaf8629..8ba139e6b 100644 --- a/test/jquery.js +++ b/test/jquery.js @@ -2,8 +2,11 @@ ( function() { /* global loadTests: false */ - var pathname = window.location.pathname, - path = pathname.slice( 0, pathname.lastIndexOf( "test" ) ), + var FILEPATH = "/test/jquery.js", + activeScript = [].slice.call( document.getElementsByTagName( "script" ), -1 )[ 0 ], + parentUrl = activeScript && activeScript.src ? + activeScript.src.replace( /[?#].*/, "" ) + FILEPATH.replace( /[^/]+/g, ".." ) + "/" : + "../", QUnit = window.QUnit || parent.QUnit, require = window.require || parent.require, @@ -17,11 +20,16 @@ // Define configuration parameters controlling how jQuery is loaded if ( QUnit ) { - QUnit.config.urlConfig.push( { - id: "amd", - label: "Load with AMD", - tooltip: "Load the AMD jQuery file (and its dependencies)" - } ); + + // AMD loading is asynchronous and incompatible with synchronous test loading in Karma + if ( !window.__karma__ ) { + QUnit.config.urlConfig.push( { + id: "amd", + label: "Load with AMD", + tooltip: "Load the AMD jQuery file (and its dependencies)" + } ); + } + QUnit.config.urlConfig.push( { id: "dev", label: "Load unminified", @@ -33,7 +41,7 @@ // This doesn't apply to iframes because they synchronously expect jQuery to be there. if ( urlParams.amd && window.QUnit ) { require.config( { - baseUrl: path + baseUrl: parentUrl } ); src = "src/jquery"; @@ -46,12 +54,7 @@ // Otherwise, load synchronously } else { - document.write( "<script id='jquery-js' src='" + path + src + "'><\x2Fscript>" ); - - // Synchronous-only tests (other tests are loaded from the test page) - if ( typeof loadTests !== "undefined" ) { - document.write( "<script src='" + path + "test/unit/ready.js'><\x2Fscript>" ); - } + document.write( "<script id='jquery-js' src='" + parentUrl + src + "'><\x2Fscript>" ); } } )(); |