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 2525cffc42)
This commit is contained in:
Michał Gołębiowski-Owczarek 2022-03-14 17:58:41 +01:00 committed by Michał Gołębiowski-Owczarek
parent be3bd560f4
commit 9bc0df70be
3 changed files with 47 additions and 24 deletions

View File

@ -9,7 +9,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
# Node.js 10 is required by jQuery infra # Node.js 10 is required by jQuery infra
NODE_VERSION: [10.x, 12.x, 14.x, 16.x] # Do not remove 16.x until jsdom tests are re-enabled on newer Node.js versions.
NODE_VERSION: [10.x, 12.x, 14.x, 16.x, 17.x]
NPM_SCRIPT: ["test:browserless"] NPM_SCRIPT: ["test:browserless"]
include: include:
- NAME: "Browser tests: full build, Chrome & Firefox stable" - NAME: "Browser tests: full build, Chrome & Firefox stable"

View File

@ -12,8 +12,17 @@ module.exports = function( grunt ) {
return data; return data;
} }
// Support: Node.js <12
// Skip running tasks that dropped support for Node.js 10
// in this Node version.
function runIfNewNode( task ) {
return oldNode ? "print_old_node_message:" + task : task;
}
var fs = require( "fs" ), var fs = require( "fs" ),
gzip = require( "gzip-js" ), gzip = require( "gzip-js" ),
oldNode = /^v10\./.test( process.version ),
nodeV17OrNewer = !/^v1[0246]\./.test( process.version ),
isCi = process.env.GITHUB_ACTION, isCi = process.env.GITHUB_ACTION,
ciBrowsers = process.env.BROWSERS && process.env.BROWSERS.split( "," ); ciBrowsers = process.env.BROWSERS && process.env.BROWSERS.split( "," );
@ -333,6 +342,15 @@ module.exports = function( grunt ) {
// Integrate jQuery specific tasks // Integrate jQuery specific tasks
grunt.loadTasks( "build/tasks" ); grunt.loadTasks( "build/tasks" );
grunt.registerTask( "print_old_node_message", ( ...args ) => {
var task = args.join( ":" );
grunt.log.writeln( "Old Node.js detected, running the task \"" + task + "\" skipped..." );
} );
grunt.registerTask( "print_jsdom_message", () => {
grunt.log.writeln( "Node.js 17 or newer detected, skipping jsdom tests..." );
} );
grunt.registerTask( "lint", [ grunt.registerTask( "lint", [
"jsonlint", "jsonlint",
@ -340,22 +358,26 @@ module.exports = function( grunt ) {
// would run the dist target first which would point to errors in the built // would run the dist target first which would point to errors in the built
// file, making it harder to fix them. We want to check the built file only // file, making it harder to fix them. We want to check the built file only
// if we already know the source files pass the linter. // if we already know the source files pass the linter.
"eslint:dev", runIfNewNode( "eslint:dev" ),
"eslint:dist" runIfNewNode( "eslint:dist" )
] ); ] );
grunt.registerTask( "lint:newer", [ grunt.registerTask( "lint:newer", [
"newer:jsonlint", "newer:jsonlint",
// Don't replace it with just the task; see the above comment. // Don't replace it with just the task; see the above comment.
"newer:eslint:dev", runIfNewNode( "newer:eslint:dev" ),
"newer:eslint:dist" runIfNewNode( "newer:eslint:dist" )
] ); ] );
grunt.registerTask( "test:fast", "node_smoke_tests" ); grunt.registerTask( "test:fast", runIfNewNode( "node_smoke_tests" ) );
grunt.registerTask( "test:slow", [ grunt.registerTask( "test:slow", [
"promises_aplus_tests", runIfNewNode( "promises_aplus_tests" ),
"karma:jsdom"
// Support: Node.js 17+
// jsdom fails to connect to the Karma server in Node 17+.
// Until we figure out a fix, skip jsdom tests there.
nodeV17OrNewer ? "print_jsdom_message" : runIfNewNode( "karma:jsdom" )
] ); ] );
grunt.registerTask( "test:prepare", [ grunt.registerTask( "test:prepare", [
@ -371,7 +393,7 @@ module.exports = function( grunt ) {
grunt.registerTask( "dev", [ grunt.registerTask( "dev", [
"build:*:*", "build:*:*",
"newer:eslint:dev", runIfNewNode( "newer:eslint:dev" ),
"newer:uglify", "newer:uglify",
"remove_map_comment", "remove_map_comment",
"dist:*", "dist:*",
@ -380,13 +402,13 @@ module.exports = function( grunt ) {
] ); ] );
grunt.registerTask( "default", [ grunt.registerTask( "default", [
"eslint:dev", runIfNewNode( "eslint:dev" ),
"build:*:*", "build:*:*",
"uglify", "uglify",
"remove_map_comment", "remove_map_comment",
"dist:*", "dist:*",
"test:prepare", "test:prepare",
"eslint:dist", runIfNewNode( "eslint:dist" ),
"test:fast", "test:fast",
"compare_size" "compare_size"
] ); ] );

View File

@ -30,29 +30,29 @@
"commitplease": "3.2.0", "commitplease": "3.2.0",
"core-js": "2.6.5", "core-js": "2.6.5",
"eslint-config-jquery": "3.0.0", "eslint-config-jquery": "3.0.0",
"grunt": "1.3.0", "grunt": "1.4.1",
"grunt-babel": "8.0.0", "grunt-babel": "8.0.0",
"grunt-cli": "1.3.2", "grunt-cli": "1.4.3",
"grunt-compare-size": "0.4.2", "grunt-compare-size": "0.4.2",
"grunt-contrib-uglify": "3.4.0", "grunt-contrib-uglify": "3.4.0",
"grunt-contrib-watch": "1.1.0", "grunt-contrib-watch": "1.1.0",
"grunt-eslint": "22.0.0", "grunt-eslint": "22.0.0",
"grunt-git-authors": "3.2.0", "grunt-git-authors": "3.2.0",
"grunt-jsonlint": "1.1.0", "grunt-jsonlint": "2.1.2",
"grunt-karma": "4.0.0", "grunt-karma": "4.0.2",
"grunt-newer": "1.3.0", "grunt-newer": "1.3.0",
"grunt-npmcopy": "0.2.0", "grunt-npmcopy": "0.2.0",
"gzip-js": "0.3.2", "gzip-js": "0.3.2",
"husky": "1.3.1", "husky": "4.2.5",
"insight": "0.10.1", "insight": "0.10.3",
"jsdom": "13.2.0", "jsdom": "19.0.0",
"karma": "5.2.3", "karma": "^6.3.17",
"karma-browserstack-launcher": "1.4.0", "karma-browserstack-launcher": "1.6.0",
"karma-chrome-launcher": "2.2.0", "karma-chrome-launcher": "3.1.1",
"karma-firefox-launcher": "1.1.0", "karma-firefox-launcher": "2.1.2",
"karma-ie-launcher": "1.0.0", "karma-ie-launcher": "1.0.0",
"karma-jsdom-launcher": "8.0.2", "karma-jsdom-launcher": "12.0.0",
"karma-qunit": "3.0.0", "karma-qunit": "4.1.2",
"load-grunt-tasks": "5.1.0", "load-grunt-tasks": "5.1.0",
"native-promise-only": "0.8.1", "native-promise-only": "0.8.1",
"promises-aplus-tests": "2.1.2", "promises-aplus-tests": "2.1.2",