Skip to content

Commit 6ddfc9d

Browse files
committed
Build/Test Tools: Switch from Puppeteer to Playwright for the QUnit test runner.
This brings the QUnit tests inline with the e2e and performance tests that switched to Playwright in #59517. This removes the `puppeteer` dependency, but `puppeteer-core` remains a transitive dependency due to `wp-scripts` and `lighthouse`. See #64894 git-svn-id: https://develop.svn.wordpress.org/trunk@62411 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a3c3968 commit 6ddfc9d

6 files changed

Lines changed: 123 additions & 184 deletions

File tree

.github/workflows/reusable-javascript-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Install npm Dependencies
5656
run: npm ci
5757

58-
# Older branches using outdated versions of Puppeteer fail on newer versions of the `ubuntu-24` image.
58+
# Branches prior to 6.1 using outdated versions of Puppeteer fail on newer versions of the `ubuntu-24` image.
5959
# This disables AppArmor in order to work around those failures.
6060
#
6161
# See https://issues.chromium.org/issues/373753919

Gruntfile.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ module.exports = function(grunt) {
115115
'cssmin',
116116
'imagemin',
117117
'jshint',
118-
'qunit',
119118
'uglify',
120119
'watch'
121120
],
@@ -955,7 +954,8 @@ module.exports = function(grunt) {
955954
src: [
956955
'tests/qunit/**/*.js',
957956
'!tests/qunit/vendor/*',
958-
'!tests/qunit/editor/**'
957+
'!tests/qunit/qunit.js',
958+
'!tests/qunit/playwright.config.js'
959959
],
960960
options: grunt.file.readJSON( 'tests/qunit/.jshintrc' )
961961
},
@@ -1059,12 +1059,6 @@ module.exports = function(grunt) {
10591059
}
10601060
}
10611061
},
1062-
qunit: {
1063-
files: [
1064-
'tests/qunit/**/*.html',
1065-
'!tests/qunit/editor/**'
1066-
]
1067-
},
10681062
phpunit: {
10691063
'default': {
10701064
args: ['--verbose', '-c', 'phpunit.xml.dist']
@@ -1597,8 +1591,7 @@ module.exports = function(grunt) {
15971591
},
15981592
test: {
15991593
files: [
1600-
'tests/qunit/**',
1601-
'!tests/qunit/editor/**'
1594+
'tests/qunit/**'
16021595
],
16031596
tasks: ['qunit']
16041597
}
@@ -2220,6 +2213,20 @@ module.exports = function(grunt) {
22202213
}, this.async());
22212214
});
22222215

2216+
grunt.registerTask( 'qunit', 'Runs QUnit tests.', function() {
2217+
var done = this.async();
2218+
grunt.util.spawn( {
2219+
cmd: 'npx',
2220+
args: [ 'playwright', 'test', '--config', 'tests/qunit/playwright.config.js' ],
2221+
opts: { stdio: 'inherit' }
2222+
}, function( error, result, code ) {
2223+
if ( code !== 0 ) {
2224+
grunt.fail.warn( 'QUnit tests failed.' );
2225+
}
2226+
done();
2227+
} );
2228+
} );
2229+
22232230
grunt.registerTask( 'qunit:compiled', 'Runs QUnit tests on compiled as well as uncompiled scripts.',
22242231
['build', 'copy:qunit', 'qunit']
22252232
);

package-lock.json

Lines changed: 0 additions & 172 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"grunt-contrib-cssmin": "~5.0.0",
5454
"grunt-contrib-imagemin": "~4.0.0",
5555
"grunt-contrib-jshint": "3.2.0",
56-
"grunt-contrib-qunit": "~10.1.1",
5756
"grunt-contrib-uglify": "~5.2.2",
5857
"grunt-contrib-watch": "~1.1.0",
5958
"grunt-file-append": "0.0.7",

tests/qunit/playwright.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Playwright configuration for QUnit tests.
3+
*/
4+
const path = require( 'path' );
5+
const { defineConfig } = require( '@playwright/test' );
6+
7+
module.exports = defineConfig( {
8+
testDir: __dirname,
9+
outputDir: path.join( __dirname, '..', '..', 'artifacts', 'test-results' ),
10+
testMatch: 'qunit.js',
11+
timeout: 30_000,
12+
workers: 1,
13+
use: {
14+
headless: true,
15+
/* This avoids the need to run `npx playwright install` in CI. */
16+
channel: process.env.CI ? 'chrome' : undefined,
17+
},
18+
reporter: process.env.CI ? 'github' : 'list',
19+
} );

0 commit comments

Comments
 (0)