Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit437f389

Browse files
authored
Build: Make dev mode work in Karma again, serve source files from disk
PRgh-4550 added support for running ES modules & AMD tests via Karma. Thisrequired reading the `esmodules` & `amd` props from both `QUnit.config` &`QUnit.urlParams`. By picking these two properties manually, the `dev` onestopped being respected while ones handled directly by QUnit were fine (like`hidepassed`). Instead of maintaining the full list of options, the code nowiterates over QUnit URL config and handles the fallbacks in a more generic way.Apart from that, all jQuery source & test files are now read directly from diskinstead of being cached by Karma so that one can run `grunt karma:chrome-debug`& work on a fix without restarting that Karma run after each change. A similareffect could have been achieved by setting `autoWatch` to `true` but then themain Karma page runs tests in an iframe by default when`grunt karma:chrome-debug` is run instead of relying on the current debug flow.Closesgh-4574Refgh-4550
1 parent0f780ba commit437f389

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed

‎Gruntfile.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,31 @@ module.exports = function( grunt ) {
158158

159159
"test/jquery.js",
160160

161-
{pattern:"dist/jquery.*",included:false,served:true},
162-
{pattern:"src/**",type:"module",included:false,served:true},
163-
{pattern:"amd/**",included:false,served:true},
161+
{
162+
pattern:"dist/jquery.*",
163+
included:false,
164+
served:true,
165+
nocache:true
166+
},
167+
{
168+
pattern:"src/**",
169+
type:"module",
170+
included:false,
171+
served:true,
172+
nocache:true
173+
},
174+
{
175+
pattern:"amd/**",
176+
included:false,
177+
served:true,
178+
nocache:true
179+
},
164180
{pattern:"node_modules/**",included:false,served:true},
165181
{
166182
pattern:"test/**/*.@(js|css|jpg|html|xml|svg)",
167183
included:false,
168-
served:true
184+
served:true,
185+
nocache:true
169186
}
170187
],
171188
reporters:["dots"],

‎test/jquery.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,34 @@
22
(function(){
33
/* global loadTests: false */
44

5-
vardynamicImportSource,
5+
vardynamicImportSource,config,src,
66
FILEPATH="/test/jquery.js",
77
activeScript=[].slice.call(document.getElementsByTagName("script"),-1)[0],
88
parentUrl=activeScript&&activeScript.src ?
99
activeScript.src.replace(/[?#].*/,"")+FILEPATH.replace(/[^/]+/g,"..")+"/" :
1010
"../",
1111
QUnit=window.QUnit,
12-
require=window.require,
12+
require=window.require;
13+
14+
functiongetQUnitConfig(){
15+
varconfig=Object.create(null);
1316

1417
// Default to unminified jQuery for directly-opened iframes
15-
config=QUnit ?
18+
if(!QUnit){
19+
config.dev=true;
20+
}else{
1621

1722
// QUnit.config is populated from QUnit.urlParams but only at the beginning
1823
// of the test run. We need to read both.
19-
{
20-
esmodules:!!(QUnit.config.esmodules||QUnit.urlParams.esmodules),
21-
amd:!!(QUnit.config.amd||QUnit.urlParams.amd)
22-
} :
24+
QUnit.config.urlConfig.forEach(function(entry){
25+
config[entry.id]=QUnit.config[entry.id]!=null ?
26+
QUnit.config[entry.id] :
27+
QUnit.urlParams[entry.id];
28+
});
29+
}
2330

24-
{dev:true},
25-
src=config.dev ?
26-
"dist/jquery.js" :
27-
"dist/jquery.min.js";
31+
returnconfig;
32+
}
2833

2934
// Define configuration parameters controlling how jQuery is loaded
3035
if(QUnit){
@@ -43,6 +48,12 @@
4348
});
4449
}
4550

51+
config=getQUnitConfig();
52+
53+
src=config.dev ?
54+
"dist/jquery.js" :
55+
"dist/jquery.min.js";
56+
4657
// Honor ES modules loading on the main window (detected by seeing QUnit on it).
4758
// This doesn't apply to iframes because they synchronously expect jQuery to be there.
4859
if(config.esmodules&&QUnit){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp