@@ -3,7 +3,7 @@ import { asyncExitHook, gracefulExit } from "exit-hook";
33import { getLatestBrowser } from "./browserstack/api.js" ;
44import { buildBrowserFromString } from "./browserstack/buildBrowserFromString.js" ;
55import { localTunnel } from "./browserstack/local.js" ;
6- import { reportEnd , reportTest } from "./reporter.js" ;
6+ import { reportEnd , reportError , reportTest } from "./reporter.js" ;
77import { createTestServer } from "./createTestServer.js" ;
88import { buildTestUrl } from "./lib/buildTestUrl.js" ;
99import { generateHash , generateModuleId } from "./lib/generateHash.js" ;
@@ -85,10 +85,10 @@ export async function run( {
8585 const reportId = message . id ;
8686 const report = reports [ reportId ] ;
8787 touchBrowser ( report . browser ) ;
88- const errors = reportTest ( message . data , report ) ;
88+ const errorMessage = reportTest ( message . data , report ) ;
8989 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 ;
9292 } else {
9393 const existing = pendingErrors [ reportId ] [ message . data . name ] ;
9494
@@ -106,6 +106,15 @@ export async function run( {
106106 }
107107 break ;
108108 }
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+ }
109118 case "runEnd" : {
110119 const reportId = message . id ;
111120 const report = reports [ reportId ] ;
@@ -127,6 +136,9 @@ export async function run( {
127136 return ;
128137 }
129138 errorMessages . push ( ...Object . values ( pendingErrors [ reportId ] ) ) ;
139+ if ( ! errorMessages . length ) {
140+ errorMessages . push ( `Global failure in ${ report . url } ` ) ;
141+ }
130142 }
131143
132144 // Run the next test
@@ -335,9 +347,9 @@ export async function run( {
335347 stop = true ;
336348 console . error (
337349 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 } )`
341353 )
342354 ) ;
343355 }
@@ -351,7 +363,8 @@ export async function run( {
351363 gracefulExit ( 0 ) ;
352364 }
353365 } 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.` ) ) ;
355368 console . log (
356369 errorMessages . map ( ( error , i ) => `\n${ i + 1 } . ${ error } ` ) . join ( "\n" )
357370 ) ;
0 commit comments