@@ -10,28 +10,28 @@ export function reportTest( test, reportId, { browser, headless } ) {
1010 return ;
1111 }
1212
13- let message = `Test ${ test . status } on ${ chalk . yellow (
13+ let message = `${ chalk . bold ( `${ test . suiteName } : ${ test . name } ` ) } ` ;
14+ message += `\nTest ${ test . status } on ${ chalk . yellow (
1415 getBrowserString ( browser , headless )
1516 ) } (${ chalk . bold ( reportId ) } ).`;
16- message += `\n${ chalk . bold ( `${ test . suiteName } : ${ test . name } ` ) } ` ;
1717
18- // Prefer failed assertions over error messages
19- if ( test . assertions . filter ( ( a ) => ! ! a && ! a . passed ) . length ) {
20- test . assertions . forEach ( ( assertion , i ) => {
21- if ( ! assertion . passed ) {
22- message += `\n${ i + 1 } . ${ chalk . red ( assertion . message ) } ` ;
23- message += `\n${ chalk . gray ( assertion . stack ) } ` ;
24- }
25- } ) ;
26- } else if ( test . errors . length ) {
18+ // test.assertions only contains passed assertions;
19+ // test.errors contains all failed asssertions
20+ if ( test . errors . length ) {
2721 for ( const error of test . errors ) {
28- message += `\n${ chalk . red ( error . message ) } ` ;
22+ message += "\n" ;
23+ message += `\n${ error . message } ` ;
2924 message += `\n${ chalk . gray ( error . stack ) } ` ;
25+ if ( error . expected && error . actual ) {
26+ message += `\nexpected: ${ JSON . stringify ( error . expected ) } ` ;
27+ message += `\nactual: ${ chalk . red ( JSON . stringify ( error . actual ) ) } ` ;
28+ }
3029 }
3130 }
3231
3332 console . log ( "\n\n" + message ) ;
3433
34+ // Only return failed messages
3535 if ( test . status === "failed" ) {
3636 return message ;
3737 }
0 commit comments