fix(tapParser/logger): Fix test duration reporting and summary formatting in TAP parser and logger

This commit is contained in:
2025-05-26 16:07:17 +00:00
parent c26145205f
commit 70435cce45
4 changed files with 26 additions and 10 deletions

View File

@@ -242,10 +242,12 @@ export class TsTestLogger {
if (!this.options.quiet) {
const total = passed + failed;
const durationStr = duration >= 1000 ? `${(duration / 1000).toFixed(1)}s` : `${duration}ms`;
if (failed === 0) {
this.log(this.format(` Summary: ${passed}/${total} PASSED`, 'green'));
this.log(this.format(` Summary: ${passed}/${total} PASSED in ${durationStr}`, 'green'));
} else {
this.log(this.format(` Summary: ${passed} passed, ${failed} failed of ${total} tests`, 'red'));
this.log(this.format(` Summary: ${passed} passed, ${failed} failed of ${total} tests in ${durationStr}`, 'red'));
}
}
@@ -392,10 +394,12 @@ export class TsTestLogger {
if (this.options.quiet) {
const status = summary.totalFailed === 0 ? 'PASSED' : 'FAILED';
const durationStr = totalDuration >= 1000 ? `${(totalDuration / 1000).toFixed(1)}s` : `${totalDuration}ms`;
if (summary.totalFailed === 0) {
this.log(`\nSummary: ${summary.totalPassed}/${summary.totalTests} | ${totalDuration}ms | ${status}`);
this.log(`\nSummary: ${summary.totalPassed}/${summary.totalTests} | ${durationStr} | ${status}`);
} else {
this.log(`\nSummary: ${summary.totalPassed} passed, ${summary.totalFailed} failed of ${summary.totalTests} tests | ${totalDuration}ms | ${status}`);
this.log(`\nSummary: ${summary.totalPassed} passed, ${summary.totalFailed} failed of ${summary.totalTests} tests | ${durationStr} | ${status}`);
}
return;
}
@@ -410,7 +414,8 @@ export class TsTestLogger {
if (summary.totalSkipped > 0) {
this.log(this.format(`│ Skipped: ${summary.totalSkipped.toString().padStart(14)}`, 'yellow'));
}
this.log(this.format(`│ Duration: ${totalDuration.toString().padStart(14)}ms │`, 'white'));
const durationStrFormatted = totalDuration >= 1000 ? `${(totalDuration / 1000).toFixed(1)}s` : `${totalDuration}ms`;
this.log(this.format(`│ Duration: ${durationStrFormatted.padStart(14)}`, 'white'));
this.log(this.format('└────────────────────────────────┘', 'dim'));
// File results