Skip to content

Commit 9bc0df7

Browse files
committed
Build: Test on Node 17, update Grunt & karma-* packages
This adds testing on Node.js 17 in addition to the currently tested 10, 12, 14 and 16 versions. Also, update Grunt & `karma-*` packages. Testing in Karma on jsdom is broken in Node 17 at the moment; until we find a fix, this change disables such testing on Node 17 or newer. Node smoke tests & promises aplus tests are disabled on Node.js 10 as they depend on jsdom and the latest jsdom version doesn't run properly on Node 10. Closes gh-5023 (cherry picked from commit 2525cff)
1 parent be3bd56 commit 9bc0df7

File tree

3 files changed

+47
-24
lines changed

3 files changed

+47
-24
lines changed

.github/workflows/node.js.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ jobs:
99
fail-fast: false
1010
matrix:
1111
# Node.js 10 is required by jQuery infra
12-
NODE_VERSION: [10.x, 12.x, 14.x, 16.x]
12+
# Do not remove 16.x until jsdom tests are re-enabled on newer Node.js versions.
13+
NODE_VERSION: [10.x, 12.x, 14.x, 16.x, 17.x]
1314
NPM_SCRIPT: ["test:browserless"]
1415
include:
1516
- NAME: "Browser tests: full build, Chrome & Firefox stable"

Gruntfile.js

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ module.exports = function( grunt ) {
1212
return data;
1313
}
1414

15+
// Support: Node.js <12
16+
// Skip running tasks that dropped support for Node.js 10
17+
// in this Node version.
18+
function runIfNewNode( task ) {
19+
return oldNode ? "print_old_node_message:" + task : task;
20+
}
21+
1522
var fs = require( "fs" ),
1623
gzip = require( "gzip-js" ),
24+
oldNode = /^v10\./.test( process.version ),
25+
nodeV17OrNewer = !/^v1[0246]\./.test( process.version ),
1726
isCi = process.env.GITHUB_ACTION,
1827
ciBrowsers = process.env.BROWSERS && process.env.BROWSERS.split( "," );
1928

@@ -333,29 +342,42 @@ module.exports = function( grunt ) {
333342
// Integrate jQuery specific tasks
334343
grunt.loadTasks( "build/tasks" );
335344

345+
grunt.registerTask( "print_old_node_message", ( ...args ) => {
346+
var task = args.join( ":" );
347+
grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
348+
} );
349+
350+
grunt.registerTask( "print_jsdom_message", () => {
351+
grunt.log.writeln( "Node.js 17 or newer detected, skipping jsdom tests..." );
352+
} );
353+
336354
grunt.registerTask( "lint", [
337355
"jsonlint",
338356

339357
// Running the full eslint task without breaking it down to targets
340358
// would run the dist target first which would point to errors in the built
341359
// file, making it harder to fix them. We want to check the built file only
342360
// if we already know the source files pass the linter.
343-
"eslint:dev",
344-
"eslint:dist"
361+
runIfNewNode( "eslint:dev" ),
362+
runIfNewNode( "eslint:dist" )
345363
] );
346364

347365
grunt.registerTask( "lint:newer", [
348366
"newer:jsonlint",
349367

350368
// Don't replace it with just the task; see the above comment.
351-
"newer:eslint:dev",
352-
"newer:eslint:dist"
369+
runIfNewNode( "newer:eslint:dev" ),
370+
runIfNewNode( "newer:eslint:dist" )
353371
] );
354372

355-
grunt.registerTask( "test:fast", "node_smoke_tests" );
373+
grunt.registerTask( "test:fast", runIfNewNode( "node_smoke_tests" ) );
356374
grunt.registerTask( "test:slow", [
357-
"promises_aplus_tests",
358-
"karma:jsdom"
375+
runIfNewNode( "promises_aplus_tests" ),
376+
377+
// Support: Node.js 17+
378+
// jsdom fails to connect to the Karma server in Node 17+.
379+
// Until we figure out a fix, skip jsdom tests there.
380+
nodeV17OrNewer ? "print_jsdom_message" : runIfNewNode( "karma:jsdom" )
359381
] );
360382

361383
grunt.registerTask( "test:prepare", [
@@ -371,7 +393,7 @@ module.exports = function( grunt ) {
371393

372394
grunt.registerTask( "dev", [
373395
"build:*:*",
374-
"newer:eslint:dev",
396+
runIfNewNode( "newer:eslint:dev" ),
375397
"newer:uglify",
376398
"remove_map_comment",
377399
"dist:*",
@@ -380,13 +402,13 @@ module.exports = function( grunt ) {
380402
] );
381403

382404
grunt.registerTask( "default", [
383-
"eslint:dev",
405+
runIfNewNode( "eslint:dev" ),
384406
"build:*:*",
385407
"uglify",
386408
"remove_map_comment",
387409
"dist:*",
388410
"test:prepare",
389-
"eslint:dist",
411+
runIfNewNode( "eslint:dist" ),
390412
"test:fast",
391413
"compare_size"
392414
] );

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@
3030
"commitplease": "3.2.0",
3131
"core-js": "2.6.5",
3232
"eslint-config-jquery": "3.0.0",
33-
"grunt": "1.3.0",
33+
"grunt": "1.4.1",
3434
"grunt-babel": "8.0.0",
35-
"grunt-cli": "1.3.2",
35+
"grunt-cli": "1.4.3",
3636
"grunt-compare-size": "0.4.2",
3737
"grunt-contrib-uglify": "3.4.0",
3838
"grunt-contrib-watch": "1.1.0",
3939
"grunt-eslint": "22.0.0",
4040
"grunt-git-authors": "3.2.0",
41-
"grunt-jsonlint": "1.1.0",
42-
"grunt-karma": "4.0.0",
41+
"grunt-jsonlint": "2.1.2",
42+
"grunt-karma": "4.0.2",
4343
"grunt-newer": "1.3.0",
4444
"grunt-npmcopy": "0.2.0",
4545
"gzip-js": "0.3.2",
46-
"husky": "1.3.1",
47-
"insight": "0.10.1",
48-
"jsdom": "13.2.0",
49-
"karma": "5.2.3",
50-
"karma-browserstack-launcher": "1.4.0",
51-
"karma-chrome-launcher": "2.2.0",
52-
"karma-firefox-launcher": "1.1.0",
46+
"husky": "4.2.5",
47+
"insight": "0.10.3",
48+
"jsdom": "19.0.0",
49+
"karma": "^6.3.17",
50+
"karma-browserstack-launcher": "1.6.0",
51+
"karma-chrome-launcher": "3.1.1",
52+
"karma-firefox-launcher": "2.1.2",
5353
"karma-ie-launcher": "1.0.0",
54-
"karma-jsdom-launcher": "8.0.2",
55-
"karma-qunit": "3.0.0",
54+
"karma-jsdom-launcher": "12.0.0",
55+
"karma-qunit": "4.1.2",
5656
"load-grunt-tasks": "5.1.0",
5757
"native-promise-only": "0.8.1",
5858
"promises-aplus-tests": "2.1.2",

0 commit comments

Comments
 (0)