@@ -80,10 +80,14 @@ export async function run( {
8080 quiet : true , // Quiet server logs during test runs
8181 testUrls,
8282 report : async ( message ) => {
83+ const reportId = message . id ;
84+ const report = reports [ reportId ] ;
85+
8386 switch ( message . type ) {
87+ case "ack" :
88+ touchBrowser ( report . browser ) ;
89+ break ;
8490 case "testEnd" : {
85- const reportId = message . id ;
86- const report = reports [ reportId ] ;
8791 touchBrowser ( report . browser ) ;
8892 const errorMessage = reportTest ( message . data , report ) ;
8993 pendingErrors [ reportId ] ??= Object . create ( null ) ;
@@ -107,17 +111,13 @@ export async function run( {
107111 break ;
108112 }
109113 case "error" : {
110- const reportId = message . id ;
111- const report = reports [ reportId ] ;
112114 touchBrowser ( report . browser ) ;
113115 const errorMessage = reportError ( message . data ) ;
114116 pendingErrors [ reportId ] ??= Object . create ( null ) ;
115117 pendingErrors [ reportId ] [ message . data . message ] = errorMessage ;
116118 break ;
117119 }
118120 case "runEnd" : {
119- const reportId = message . id ;
120- const report = reports [ reportId ] ;
121121 touchBrowser ( report . browser ) ;
122122 const { failed, total } = reportEnd ( message . data , reports [ reportId ] ) ;
123123 report . total = total ;
@@ -144,11 +144,6 @@ export async function run( {
144144 // Run the next test
145145 return getNextBrowserTest ( reportId ) ;
146146 }
147- case "ack" : {
148- const report = reports [ message . id ] ;
149- touchBrowser ( report . browser ) ;
150- break ;
151- }
152147 default :
153148 console . warn ( "Received unknown message type:" , message . type ) ;
154149 }
@@ -340,16 +335,16 @@ export async function run( {
340335 }
341336 } finally {
342337 console . log ( ) ;
343- if ( errorMessages . length === 0 ) {
338+ const numErrors = errorMessages . length ;
339+ if ( numErrors === 0 ) {
344340 let stop = false ;
345341 for ( const report of Object . values ( reports ) ) {
346342 if ( ! report . total ) {
347343 stop = true ;
348344 console . error (
349345 chalk . red (
350- `No tests were run with URL "${ report . url } " in ${
351- report . fullBrowser
352- } (${ report . id } )`
346+ `No tests were run with URL "${ report . url } " ` +
347+ `in ${ report . fullBrowser } (${ report . id } )`
353348 )
354349 ) ;
355350 }
@@ -363,8 +358,9 @@ export async function run( {
363358 gracefulExit ( 0 ) ;
364359 }
365360 } else {
366- const len = errorMessages . length ;
367- console . error ( chalk . red ( `${ len } test${ len > 1 ? "s" : "" } failed.` ) ) ;
361+ console . error (
362+ chalk . red ( `${ numErrors } test${ numErrors > 1 ? "s" : "" } failed.` )
363+ ) ;
368364 console . log (
369365 errorMessages . map ( ( error , i ) => `\n${ i + 1 } . ${ error } ` ) . join ( "\n" )
370366 ) ;
0 commit comments