aboutsummaryrefslogtreecommitdiffstats
path: root/Gruntfile.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2023-01-23 23:49:44 +0100
committerGitHub <noreply@github.com>2023-01-23 23:49:44 +0100
commitb02a257f98688aa890e06a85672cd1a54c3ffa3a (patch)
tree0c5496cb1e61a964e35c73aa5696d0cc245e4f5f /Gruntfile.js
parentce90a48450ba40586a6567235abb8fd2df84da97 (diff)
downloadjquery-b02a257f98688aa890e06a85672cd1a54c3ffa3a.tar.gz
jquery-b02a257f98688aa890e06a85672cd1a54c3ffa3a.zip
Build: Run GitHub Action browser tests on Playwright WebKit
So far, we've been running browser tests on GitHub Actions in Chrome and Firefox. Regular Safari is not available in GitHub Actions but Playwright WebKit comes close to a dev version of Safari. With this change, our GitHub CI & local test runs will invoke tests on all actively developed browser engines on all PRs. Also, our GitHub Actions browser tests are now running on Node.js 18. Detection of the Playwright WebKit browser in support unit tests is done by checking if the `test_browser` query parameter is set to `"Playwright"`; this is a `karma-webkit-launcher` feature. Detecting that browser via user agent as we normally do is hard as the UA on Linux is very similar to a real Safari one but it actually uses a newer version of the engine. In addition, we now allow to pass custom browsers when one needs it; e.g., to run the tests in all three engines on Linux/macOS, run: ``` grunt && BROWSERS=ChromeHeadless,FirefoxHeadless,WebkitHeadless grunt karma:main ``` Closes gh-5190
Diffstat (limited to 'Gruntfile.js')
-rw-r--r--Gruntfile.js35
1 files changed, 20 insertions, 15 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
index 3a56cb4e4..f24e8a448 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -2,8 +2,8 @@
module.exports = function( grunt ) {
function readOptionalJSON( filepath ) {
- var stripJSONComments = require( "strip-json-comments" ),
- data = {};
+ const stripJSONComments = require( "strip-json-comments" );
+ let data = {};
try {
data = JSON.parse( stripJSONComments(
fs.readFileSync( filepath, { encoding: "utf8" } )
@@ -12,19 +12,23 @@ module.exports = function( grunt ) {
return data;
}
- // Support: Node.js <12
- // Skip running tasks that dropped support for Node.js 10
+ const fs = require( "fs" );
+ const gzip = require( "gzip-js" );
+ const nodeV14OrNewer = !/^v1[0-3]\./.test( process.version );
+ const nodeV17OrNewer = !/^v1[0-6]\./.test( process.version );
+ const customBrowsers = process.env.BROWSERS && process.env.BROWSERS.split( "," );
+
+ // Support: Node.js <14
+ // Skip running tasks that dropped support for Node.js 10 or 12
// in this Node version.
function runIfNewNode( task ) {
- return oldNode ? "print_old_node_message:" + task : task;
+ return nodeV14OrNewer ? task : "print_old_node_message:" + task;
}
- var fs = require( "fs" ),
- gzip = require( "gzip-js" ),
- oldNode = /^v10\./.test( process.version ),
- nodeV17OrNewer = !/^v1[0246]\./.test( process.version ),
- isCi = process.env.GITHUB_ACTION,
- ciBrowsers = process.env.BROWSERS && process.env.BROWSERS.split( "," );
+ if ( nodeV14OrNewer ) {
+ const playwright = require( "playwright-webkit" );
+ process.env.WEBKIT_HEADLESS_BIN = playwright.webkit.executablePath();
+ }
if ( !grunt.option( "filename" ) ) {
grunt.option( "filename", "jquery.js" );
@@ -242,10 +246,11 @@ module.exports = function( grunt ) {
singleRun: true
},
main: {
- browsers: isCi && ciBrowsers || [ "ChromeHeadless", "FirefoxHeadless" ]
+ browsers: customBrowsers ||
+ [ "ChromeHeadless", "FirefoxHeadless", "WebkitHeadless" ]
},
esmodules: {
- browsers: isCi && ciBrowsers || [ "ChromeHeadless" ],
+ browsers: customBrowsers || [ "ChromeHeadless" ],
options: {
client: {
qunit: {
@@ -260,7 +265,7 @@ module.exports = function( grunt ) {
}
},
amd: {
- browsers: isCi && ciBrowsers || [ "ChromeHeadless" ],
+ browsers: customBrowsers || [ "ChromeHeadless" ],
options: {
client: {
qunit: {
@@ -352,7 +357,7 @@ module.exports = function( grunt ) {
// Load grunt tasks from NPM packages
require( "load-grunt-tasks" )( grunt, {
- pattern: oldNode ? [ "grunt-*", "!grunt-eslint" ] : [ "grunt-*" ]
+ pattern: nodeV14OrNewer ? [ "grunt-*" ] : [ "grunt-*", "!grunt-eslint" ]
} );
// Integrate jQuery specific tasks