Skip to content

Commit

Permalink
Tests: show any and all actual/expected values
Browse files Browse the repository at this point in the history
Close gh-5448
  • Loading branch information
timmywil committed Mar 15, 2024
1 parent 44fb7fa commit f80e78e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/runner/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ export function reportTest( test, reportId, { browser, headless } ) {
if ( test.errors.length ) {
for ( const error of test.errors ) {
message += "\n";
message += `\n${ error.message }`;
if ( error.message ) {
message += `\n${ error.message }`;
}
message += `\n${ chalk.gray( error.stack ) }`;
if ( error.expected && error.actual ) {
if ( "expected" in error && "actual" in error ) {
message += `\nexpected: ${ JSON.stringify( error.expected ) }`;
message += `\nactual: ${ JSON.stringify( error.actual ) }`;
let diff;
Expand Down Expand Up @@ -54,6 +56,13 @@ export function reportTest( test, reportId, { browser, headless } ) {
} else {
diff = [ { removed: true, value: `${ value }` } ];
}
} else if (
typeof error.expected === "boolean" &&
typeof error.actual === "boolean"
) {

// Show the actual boolean in red
diff = [ { removed: true, value: `${ error.actual }` } ];
} else {

// Diff everything else as characters
Expand Down

0 comments on commit f80e78e

Please sign in to comment.