@@ -80,11 +80,12 @@ 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
+ touchBrowser ( report . browser ) ;
86
+
83
87
switch ( message . type ) {
84
88
case "testEnd" : {
85
- const reportId = message . id ;
86
- const report = reports [ reportId ] ;
87
- touchBrowser ( report . browser ) ;
88
89
const errorMessage = reportTest ( message . data , report ) ;
89
90
pendingErrors [ reportId ] ??= Object . create ( null ) ;
90
91
if ( errorMessage ) {
@@ -107,18 +108,12 @@ export async function run( {
107
108
break ;
108
109
}
109
110
case "error" : {
110
- const reportId = message . id ;
111
- const report = reports [ reportId ] ;
112
- touchBrowser ( report . browser ) ;
113
111
const errorMessage = reportError ( message . data ) ;
114
112
pendingErrors [ reportId ] ??= Object . create ( null ) ;
115
113
pendingErrors [ reportId ] [ message . data . message ] = errorMessage ;
116
114
break ;
117
115
}
118
116
case "runEnd" : {
119
- const reportId = message . id ;
120
- const report = reports [ reportId ] ;
121
- touchBrowser ( report . browser ) ;
122
117
const { failed, total } = reportEnd ( message . data , reports [ reportId ] ) ;
123
118
report . total = total ;
124
119
@@ -144,11 +139,6 @@ export async function run( {
144
139
// Run the next test
145
140
return getNextBrowserTest ( reportId ) ;
146
141
}
147
- case "ack" : {
148
- const report = reports [ message . id ] ;
149
- touchBrowser ( report . browser ) ;
150
- break ;
151
- }
152
142
default :
153
143
console . warn ( "Received unknown message type:" , message . type ) ;
154
144
}
@@ -340,16 +330,16 @@ export async function run( {
340
330
}
341
331
} finally {
342
332
console . log ( ) ;
343
- if ( errorMessages . length === 0 ) {
333
+ const numErrors = errorMessages . length ;
334
+ if ( numErrors === 0 ) {
344
335
let stop = false ;
345
336
for ( const report of Object . values ( reports ) ) {
346
337
if ( ! report . total ) {
347
338
stop = true ;
348
339
console . error (
349
340
chalk . red (
350
- `No tests were run with URL "${ report . url } " in ${
351
- report . fullBrowser
352
- } (${ report . id } )`
341
+ `No tests were run with URL "${ report . url } " ` +
342
+ `in ${ report . fullBrowser } (${ report . id } )`
353
343
)
354
344
) ;
355
345
}
@@ -363,8 +353,9 @@ export async function run( {
363
353
gracefulExit ( 0 ) ;
364
354
}
365
355
} else {
366
- const len = errorMessages . length ;
367
- console . error ( chalk . red ( `${ len } test${ len > 1 ? "s" : "" } failed.` ) ) ;
356
+ console . error (
357
+ chalk . red ( `${ numErrors } test${ numErrors > 1 ? "s" : "" } failed.` )
358
+ ) ;
368
359
console . log (
369
360
errorMessages . map ( ( error , i ) => `\n${ i + 1 } . ${ error } ` ) . join ( "\n" )
370
361
) ;
0 commit comments