@@ -3,7 +3,7 @@ import { asyncExitHook, gracefulExit } from "exit-hook";
3
3
import { getLatestBrowser } from "./browserstack/api.js" ;
4
4
import { buildBrowserFromString } from "./browserstack/buildBrowserFromString.js" ;
5
5
import { localTunnel } from "./browserstack/local.js" ;
6
- import { reportEnd , reportTest } from "./reporter.js" ;
6
+ import { reportEnd , reportError , reportTest } from "./reporter.js" ;
7
7
import { createTestServer } from "./createTestServer.js" ;
8
8
import { buildTestUrl } from "./lib/buildTestUrl.js" ;
9
9
import { generateHash , generateModuleId } from "./lib/generateHash.js" ;
@@ -85,10 +85,10 @@ export async function run( {
85
85
const reportId = message . id ;
86
86
const report = reports [ reportId ] ;
87
87
touchBrowser ( report . browser ) ;
88
- const errors = reportTest ( message . data , report ) ;
88
+ const errorMessage = reportTest ( message . data , report ) ;
89
89
pendingErrors [ reportId ] ??= Object . create ( null ) ;
90
- if ( errors ) {
91
- pendingErrors [ reportId ] [ message . data . name ] = errors ;
90
+ if ( errorMessage ) {
91
+ pendingErrors [ reportId ] [ message . data . name ] = errorMessage ;
92
92
} else {
93
93
const existing = pendingErrors [ reportId ] [ message . data . name ] ;
94
94
@@ -106,6 +106,15 @@ export async function run( {
106
106
}
107
107
break ;
108
108
}
109
+ case "error" : {
110
+ const reportId = message . id ;
111
+ const report = reports [ reportId ] ;
112
+ touchBrowser ( report . browser ) ;
113
+ const errorMessage = reportError ( message . data ) ;
114
+ pendingErrors [ reportId ] ??= Object . create ( null ) ;
115
+ pendingErrors [ reportId ] [ message . data . message ] = errorMessage ;
116
+ break ;
117
+ }
109
118
case "runEnd" : {
110
119
const reportId = message . id ;
111
120
const report = reports [ reportId ] ;
@@ -127,6 +136,9 @@ export async function run( {
127
136
return ;
128
137
}
129
138
errorMessages . push ( ...Object . values ( pendingErrors [ reportId ] ) ) ;
139
+ if ( ! errorMessages . length ) {
140
+ errorMessages . push ( `Global failure in ${ report . url } ` ) ;
141
+ }
130
142
}
131
143
132
144
// Run the next test
@@ -335,9 +347,9 @@ export async function run( {
335
347
stop = true ;
336
348
console . error (
337
349
chalk . red (
338
- `No tests were run with URL "${ report . url } " in ${ getBrowserString (
339
- report . browser
340
- ) } (${ report . id } )`
350
+ `No tests were run with URL "${ report . url } " in ${
351
+ report . fullBrowser
352
+ } (${ report . id } )`
341
353
)
342
354
) ;
343
355
}
@@ -351,7 +363,8 @@ export async function run( {
351
363
gracefulExit ( 0 ) ;
352
364
}
353
365
} else {
354
- console . error ( chalk . red ( `${ errorMessages . length } tests failed.` ) ) ;
366
+ const len = errorMessages . length ;
367
+ console . error ( chalk . red ( `${ len } test${ len > 1 ? "s" : "" } failed.` ) ) ;
355
368
console . log (
356
369
errorMessages . map ( ( error , i ) => `\n${ i + 1 } . ${ error } ` ) . join ( "\n" )
357
370
) ;
0 commit comments