Skip to content

Commit cb705dd

Browse files
committed
fixup! build error message with error.name; share reportError message
1 parent c0f3b10 commit cb705dd

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

listeners.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@
8787
send( "ack" );
8888

8989
QUnit.on( "error", function( error ) {
90-
send( "error", { message: error.message, stack: error.stack } );
90+
send( "error", {
91+
message: error.message,
92+
name: error.name,
93+
stack: error.stack
94+
} );
9195
} );
9296

9397
QUnit.on( "testEnd", function( data ) {

reporter.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,14 @@ export function reportTest( test, { fullBrowser, id } ) {
114114
}
115115

116116
export function reportError( error ) {
117-
console.error( chalk.red( `\n\nError: ${ error.message }` ) );
118-
console.error( chalk.gray( error.stack ) );
119-
return error;
117+
const title = `${ error.name || "Error" }: ${ error.message }`;
118+
let message = chalk.red( title );
119+
120+
// Chromium error stacks include the title in the first line,
121+
// but Firefox error stacks do not.
122+
message += `\n${ chalk.gray( error.stack.replace( `${ title }\n`, "" ) ) }`;
123+
console.error( `\n\n${ message }` );
124+
return message;
120125
}
121126

122127
export function reportEnd( result, { descriptiveUrl, fullBrowser, id } ) {

run.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ export async function run( {
110110
const reportId = message.id;
111111
const report = reports[ reportId ];
112112
touchBrowser( report.browser );
113-
reportError( message.data );
113+
const errorMessage = reportError( message.data );
114114
pendingErrors[ reportId ] ??= Object.create( null );
115-
pendingErrors[ reportId ][ message.data.message ] =
116-
`${ message.data.message }\n${ message.data.stack }`;
115+
pendingErrors[ reportId ][ message.data.message ] = errorMessage;
117116
break;
118117
}
119118
case "runEnd": {

0 commit comments

Comments
 (0)