@@ -80,10 +80,14 @@ export async function run( {
80
80
quiet : true , // Quiet server logs during test runs
81
81
testUrls,
82
82
report : async ( message ) => {
83
+ const reportId = message . id ;
84
+ const report = reports [ reportId ] ;
85
+
83
86
switch ( message . type ) {
87
+ case "ack" :
88
+ touchBrowser ( report . browser ) ;
89
+ break ;
84
90
case "testEnd" : {
85
- const reportId = message . id ;
86
- const report = reports [ reportId ] ;
87
91
touchBrowser ( report . browser ) ;
88
92
const errorMessage = reportTest ( message . data , report ) ;
89
93
pendingErrors [ reportId ] ??= Object . create ( null ) ;
@@ -107,17 +111,13 @@ export async function run( {
107
111
break ;
108
112
}
109
113
case "error" : {
110
- const reportId = message . id ;
111
- const report = reports [ reportId ] ;
112
114
touchBrowser ( report . browser ) ;
113
115
const errorMessage = reportError ( message . data ) ;
114
116
pendingErrors [ reportId ] ??= Object . create ( null ) ;
115
117
pendingErrors [ reportId ] [ message . data . message ] = errorMessage ;
116
118
break ;
117
119
}
118
120
case "runEnd" : {
119
- const reportId = message . id ;
120
- const report = reports [ reportId ] ;
121
121
touchBrowser ( report . browser ) ;
122
122
const { failed, total } = reportEnd ( message . data , reports [ reportId ] ) ;
123
123
report . total = total ;
@@ -144,11 +144,6 @@ export async function run( {
144
144
// Run the next test
145
145
return getNextBrowserTest ( reportId ) ;
146
146
}
147
- case "ack" : {
148
- const report = reports [ message . id ] ;
149
- touchBrowser ( report . browser ) ;
150
- break ;
151
- }
152
147
default :
153
148
console . warn ( "Received unknown message type:" , message . type ) ;
154
149
}
@@ -340,16 +335,16 @@ export async function run( {
340
335
}
341
336
} finally {
342
337
console . log ( ) ;
343
- if ( errorMessages . length === 0 ) {
338
+ const numErrors = errorMessages . length ;
339
+ if ( numErrors === 0 ) {
344
340
let stop = false ;
345
341
for ( const report of Object . values ( reports ) ) {
346
342
if ( ! report . total ) {
347
343
stop = true ;
348
344
console . error (
349
345
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 } )`
353
348
)
354
349
) ;
355
350
}
@@ -363,8 +358,9 @@ export async function run( {
363
358
gracefulExit ( 0 ) ;
364
359
}
365
360
} 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
+ ) ;
368
364
console . log (
369
365
errorMessages . map ( ( error , i ) => `\n${ i + 1 } . ${ error } ` ) . join ( "\n" )
370
366
) ;
0 commit comments