Skip to content

Commit e5c2cf0

Browse files
committed
Address PR feedback.
1 parent 9c7881f commit e5c2cf0

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,8 +2168,8 @@ module.exports = function(grunt) {
21682168
grunt.registerTask( 'qunit', 'Runs QUnit tests.', function() {
21692169
var done = this.async();
21702170
grunt.util.spawn( {
2171-
cmd: 'node_modules/.bin/playwright',
2172-
args: [ 'test', '--config', 'tests/qunit/playwright.config.js' ],
2171+
cmd: 'npx',
2172+
args: [ 'playwright', 'test', '--config', 'tests/qunit/playwright.config.js' ],
21732173
opts: { stdio: 'inherit' }
21742174
}, function( error, result, code ) {
21752175
if ( code !== 0 ) {

tests/qunit/playwright.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = defineConfig( {
1212
workers: 1,
1313
use: {
1414
headless: true,
15-
channel: 'chrome',
15+
/* This avoids the need to run `npx playwright install` in CI. */
16+
channel: process.env.CI ? 'chrome' : undefined,
1617
},
1718
reporter: process.env.CI ? 'github' : 'list',
1819
} );

tests/qunit/qunit.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
const { test, expect } = require( '@playwright/test' );
2+
const fs = require( 'fs' );
23
const path = require( 'path' );
3-
const glob = require( 'fast-glob' );
4+
const { pathToFileURL } = require( 'url' );
5+
6+
function getHtmlFiles( dir ) {
7+
const entries = fs.readdirSync( dir, { withFileTypes: true } );
8+
9+
return entries.flatMap( ( entry ) => {
10+
const entryPath = path.join( dir, entry.name );
11+
12+
if ( entry.isDirectory() ) {
13+
return getHtmlFiles( entryPath );
14+
}
15+
16+
return entry.isFile() && entry.name.endsWith( '.html' ) ? [ entryPath ] : [];
17+
} );
18+
}
419

520
const qunitDir = path.resolve( __dirname );
6-
const htmlFiles = glob.sync( [ '**/*.html' ], {
7-
cwd: qunitDir,
8-
absolute: true,
9-
} );
21+
const htmlFiles = getHtmlFiles( qunitDir );
1022

1123
for ( const file of htmlFiles ) {
1224
const name = path.relative( qunitDir, file );
@@ -51,7 +63,7 @@ for ( const file of htmlFiles ) {
5163
} );
5264

5365
// Navigate to the test file.
54-
await page.goto( 'file://' + file, { waitUntil: 'domcontentloaded' } );
66+
await page.goto( pathToFileURL( file ).href, { waitUntil: 'domcontentloaded' } );
5567

5668
// Wait for QUnit to complete.
5769
const results = await page.evaluate( () => window.__qunitResults );

0 commit comments

Comments
 (0)