77// Note: can be converted to ts file once node 20 support is dropped.
88// Node 20 does not support --experimental-strip-types flag.
99
10- import { spawn , execSync } from 'node:child_process' ;
10+ import { spawn } from 'node:child_process' ;
1111import { readFile } from 'node:fs/promises' ;
1212import path from 'node:path' ;
1313import process from 'node:process' ;
@@ -37,22 +37,20 @@ if (userArgs.length > 0) {
3737 }
3838 files . push ( testPath ) ;
3939 }
40- } else {
41- if ( flags . includes ( '--test-only' ) ) {
42- const { glob} = await import ( 'node:fs/promises' ) ;
43- for await ( const tsFile of glob ( 'tests/**/*.test.ts' ) ) {
44- const content = await readFile ( tsFile , 'utf8' ) ;
45- if ( content . includes ( '.only(' ) ) {
46- files . push ( path . join ( 'build' , tsFile . replace ( / \. t s $ / , '.js' ) ) ) ;
47- }
48- }
49- if ( files . length === 0 ) {
50- console . warn ( 'no files contain .only' ) ;
51- process . exit ( 0 ) ;
40+ } else if ( flags . includes ( '--test-only' ) ) {
41+ const { glob} = await import ( 'node:fs/promises' ) ;
42+ for await ( const tsFile of glob ( 'tests/**/*.test.ts' ) ) {
43+ const content = await readFile ( tsFile , 'utf8' ) ;
44+ if ( content . includes ( '.only(' ) ) {
45+ files . push ( path . join ( 'build' , tsFile . replace ( / \. t s $ / , '.js' ) ) ) ;
5246 }
53- } else if ( files . length === 0 ) {
54- files . push ( 'build/tests/**/*.test.js' ) ;
5547 }
48+ if ( files . length === 0 ) {
49+ console . warn ( 'no files contain .only' ) ;
50+ process . exit ( 0 ) ;
51+ }
52+ } else if ( files . length === 0 ) {
53+ files . push ( 'build/tests/**/*.test.js' ) ;
5654}
5755
5856const nodeArgs = [
@@ -68,24 +66,11 @@ const nodeArgs = [
6866 ...files ,
6967] ;
7068
71- function _installChrome ( version ) {
72- try {
73- return execSync (
74- `npx puppeteer browsers install chrome@${ version } --format "{{path}}"` ,
75- )
76- . toString ( )
77- . trim ( ) ;
78- } catch ( e ) {
79- console . error ( `Failed to install Chrome ${ version } :` , e ) ;
80- process . exit ( 1 ) ;
81- }
82- }
83-
8469async function runTests ( attempt ) {
8570 if ( attempt > 1 ) {
8671 console . log ( `\nRun attempt ${ attempt } ...\n` ) ;
8772 }
88- return new Promise ( resolve => {
73+ return await new Promise ( resolve => {
8974 const child = spawn ( 'node' , nodeArgs , {
9075 stdio : 'inherit' ,
9176 env : {
0 commit comments