@@ -8,28 +8,43 @@ module.exports = function( grunt ) {
8
8
9
9
const oldNode = / ^ v 1 0 \. / . test ( process . version ) ;
10
10
11
- const karmaFilesExceptJQuery = [
11
+ const karmaQunitConfig = {
12
+ showUI : true ,
13
+ testTimeout : 5000 ,
14
+
15
+ // We're running `QUnit.start()` ourselves in
16
+ // test/data/qunit-start.js
17
+ autostart : false
18
+ } ;
19
+
20
+ const karmaFilesExceptJQueryAndMigrate = [
21
+
22
+ // In esmodules mode only object entries of this array with `type: "js"`
23
+ // get the `type: "module"` tweak. npo is incompatible with being loaded as
24
+ // a module so leverage this hack to prevent loading it in this way.
12
25
"external/npo/npo.js" ,
13
- "dist/jquery-migrate.min.js" ,
14
- "test/data/compareVersions.js" ,
15
-
16
- "test/data/testinit.js" ,
17
- "test/data/test-utils.js" ,
18
- "test/unit/migrate.js" ,
19
- "test/unit/jquery/core.js" ,
20
- "test/unit/jquery/ajax.js" ,
21
- "test/unit/jquery/attributes.js" ,
22
- "test/unit/jquery/css.js" ,
23
- "test/unit/jquery/data.js" ,
24
- "test/unit/jquery/deferred.js" ,
25
- "test/unit/jquery/effects.js" ,
26
- "test/unit/jquery/event.js" ,
27
- "test/unit/jquery/manipulation.js" ,
28
- "test/unit/jquery/offset.js" ,
29
- "test/unit/jquery/serialize.js" ,
30
- "test/unit/jquery/traversing.js" ,
31
-
32
- { pattern : "dist/jquery-migrate.js" , included : false , served : true } ,
26
+
27
+ { pattern : "test/data/compareVersions.js" , type : "js" , nocache : true } ,
28
+
29
+ { pattern : "test/data/testinit.js" , type : "js" , nocache : true } ,
30
+ { pattern : "test/data/test-utils.js" , type : "js" , nocache : true } ,
31
+ { pattern : "test/unit/migrate.js" , type : "js" , nocache : true } ,
32
+ { pattern : "test/unit/jquery/core.js" , type : "js" , nocache : true } ,
33
+ { pattern : "test/unit/jquery/ajax.js" , type : "js" , nocache : true } ,
34
+ { pattern : "test/unit/jquery/attributes.js" , type : "js" , nocache : true } ,
35
+ { pattern : "test/unit/jquery/css.js" , type : "js" , nocache : true } ,
36
+ { pattern : "test/unit/jquery/data.js" , type : "js" , nocache : true } ,
37
+ { pattern : "test/unit/jquery/deferred.js" , type : "js" , nocache : true } ,
38
+ { pattern : "test/unit/jquery/effects.js" , type : "js" , nocache : true } ,
39
+ { pattern : "test/unit/jquery/event.js" , type : "js" , nocache : true } ,
40
+ { pattern : "test/unit/jquery/manipulation.js" , type : "js" , nocache : true } ,
41
+ { pattern : "test/unit/jquery/offset.js" , type : "js" , nocache : true } ,
42
+ { pattern : "test/unit/jquery/serialize.js" , type : "js" , nocache : true } ,
43
+ { pattern : "test/unit/jquery/traversing.js" , type : "js" , nocache : true } ,
44
+
45
+ { pattern : "test/data/qunit-start.js" , type : "js" , nocache : true } ,
46
+
47
+ { pattern : "dist/jquery-migrate.js" , included : false , served : true , nocache : true } ,
33
48
{ pattern : "test/**/*.@(js|json|css|jpg|html|xml)" , included : false , served : true }
34
49
] ;
35
50
@@ -182,14 +197,12 @@ module.exports = function( grunt ) {
182
197
frameworks : [ "qunit" ] ,
183
198
files : [
184
199
"https://releases.jquery.com/git/jquery-3.x-git.min.js" ,
185
- ...karmaFilesExceptJQuery
200
+ "dist/jquery-migrate.min.js" ,
201
+ ...karmaFilesExceptJQueryAndMigrate
186
202
] ,
187
203
client : {
188
204
clearContext : false ,
189
- qunit : {
190
- showUI : true ,
191
- testTimeout : 5000
192
- }
205
+ qunit : karmaQunitConfig
193
206
} ,
194
207
reporters : [ "dots" ] ,
195
208
autoWatch : false ,
@@ -207,11 +220,51 @@ module.exports = function( grunt ) {
207
220
options : {
208
221
files : [
209
222
"https://releases.jquery.com/git/jquery-3.x-git.slim.min.js" ,
210
- ...karmaFilesExceptJQuery
223
+ "dist/jquery-migrate.min.js" ,
224
+ ...karmaFilesExceptJQueryAndMigrate
211
225
]
212
226
}
213
227
} ,
214
228
229
+ esmodules : {
230
+ browsers : [ "ChromeHeadless" , "FirefoxHeadless" ] ,
231
+ options : {
232
+ files : [
233
+ "https://releases.jquery.com/git/jquery-3.x-git.slim.min.js" ,
234
+ { pattern : "src/migrate.js" , type : "module" } ,
235
+
236
+ // Silence console warnings to avoid flooding the console.
237
+ { pattern : "src/migratemute.js" , type : "module" } ,
238
+
239
+ // Only object entries with `type: "js"` get
240
+ // the `type: "module"` tweak.
241
+ ...karmaFilesExceptJQueryAndMigrate . map ( file => {
242
+ if ( file && typeof file === "object" && file . type === "js" ) {
243
+ return {
244
+ ...file ,
245
+ type : "module"
246
+ } ;
247
+ } else {
248
+ return file ;
249
+ }
250
+ } ) ,
251
+
252
+ {
253
+ pattern : "src/**" ,
254
+ included : false ,
255
+ type : "module" ,
256
+ served : true
257
+ }
258
+ ] ,
259
+ client : {
260
+ qunit : {
261
+ ...karmaQunitConfig ,
262
+ plugin : "esmodules"
263
+ }
264
+ }
265
+ }
266
+ } ,
267
+
215
268
// To debug tests with Karma:
216
269
// 1. Run 'grunt karma:chrome-debug' or 'grunt karma:firefox-debug'
217
270
// (any karma subtask that has singleRun=false)
@@ -247,7 +300,8 @@ module.exports = function( grunt ) {
247
300
// Just an alias
248
301
grunt . registerTask ( "test" , [
249
302
"karma:main" ,
250
- "karma:jquery-slim"
303
+ "karma:jquery-slim" ,
304
+ "karma:esmodules"
251
305
] ) ;
252
306
253
307
grunt . registerTask ( "lint" , [
0 commit comments