@@ -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" ;
@@ -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
+ reportError ( message . data ) ;
114
+ pendingErrors [ reportId ] ??= Object . create ( null ) ;
115
+ pendingErrors [ reportId ] [ message . data . message ] = message . data . stack ;
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
@@ -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