aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimmy Willison <timmywil@users.noreply.github.com>2024-03-14 09:05:42 -0400
committerGitHub <noreply@github.com>2024-03-14 09:05:42 -0400
commit1e84908baf13da63c33ee66c857e45c2f02eced7 (patch)
tree045eafac9329c395f3e3e6446ee78b5c2ba66b42
parent60f11b58bfeece6b6d0189d7d19b61a4e1e61139 (diff)
downloadjquery-1e84908baf13da63c33ee66c857e45c2f02eced7.tar.gz
jquery-1e84908baf13da63c33ee66c857e45c2f02eced7.zip
Tests: add actual and expected messages to test reporter
Close gh-5443
-rw-r--r--test/runner/reporter.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/test/runner/reporter.js b/test/runner/reporter.js
index bb5e7601b..74417f2fb 100644
--- a/test/runner/reporter.js
+++ b/test/runner/reporter.js
@@ -10,28 +10,28 @@ export function reportTest( test, reportId, { browser, headless } ) {
return;
}
- let message = `Test ${ test.status } on ${ chalk.yellow(
+ let message = `${ chalk.bold( `${ test.suiteName }: ${ test.name }` ) }`;
+ message += `\nTest ${ test.status } on ${ chalk.yellow(
getBrowserString( browser, headless )
) } (${ chalk.bold( reportId ) }).`;
- message += `\n${ chalk.bold( `${ test.suiteName }: ${ test.name }` ) }`;
- // Prefer failed assertions over error messages
- if ( test.assertions.filter( ( a ) => !!a && !a.passed ).length ) {
- test.assertions.forEach( ( assertion, i ) => {
- if ( !assertion.passed ) {
- message += `\n${ i + 1 }. ${ chalk.red( assertion.message ) }`;
- message += `\n${ chalk.gray( assertion.stack ) }`;
- }
- } );
- } else if ( test.errors.length ) {
+ // test.assertions only contains passed assertions;
+ // test.errors contains all failed asssertions
+ if ( test.errors.length ) {
for ( const error of test.errors ) {
- message += `\n${ chalk.red( error.message ) }`;
+ message += "\n";
+ message += `\n${ error.message }`;
message += `\n${ chalk.gray( error.stack ) }`;
+ if ( error.expected && error.actual ) {
+ message += `\nexpected: ${ JSON.stringify( error.expected ) }`;
+ message += `\nactual: ${ chalk.red( JSON.stringify( error.actual ) ) }`;
+ }
}
}
console.log( "\n\n" + message );
+ // Only return failed messages
if ( test.status === "failed" ) {
return message;
}