From be4e107c8500adfc9212e9292b376a86b1a56f9d Mon Sep 17 00:00:00 2001 From: Adam Gastineau Date: Fri, 14 Feb 2025 10:19:07 -0800 Subject: [PATCH] TerminalReporter display of warnings --- packages/playwright/src/reporters/base.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts index 1748cac9b9..9c82f6a504 100644 --- a/packages/playwright/src/reporters/base.ts +++ b/packages/playwright/src/reporters/base.ts @@ -270,6 +270,7 @@ export class TerminalReporter implements ReporterV2 { if (full && summary.failuresToPrint.length && !this._omitFailures) this._printFailures(summary.failuresToPrint); this._printSlowTests(); + this._printWarnings(); this._printSummary(summaryMessage); } @@ -289,6 +290,28 @@ export class TerminalReporter implements ReporterV2 { console.log(this.screen.colors.yellow(' Consider running tests from slow files in parallel, see https://playwright.dev/docs/test-parallel.')); } + private _printWarnings() { + const warningTests = this.suite.allTests().filter(test => test.annotations.some(a => a.type === 'warning')); + const encounteredWarnings = new Map>(); + for (const test of warningTests) { + for (const annotation of test.annotations) { + if (annotation.type !== 'warning' || annotation.description === undefined) + continue; + let tests = encounteredWarnings.get(annotation.description); + if (!tests) { + tests = []; + encounteredWarnings.set(annotation.description, tests); + } + tests.push(test); + } + } + for (const [description, tests] of encounteredWarnings) { + console.log(this.screen.colors.yellow(' Warning: ') + description); + for (const test of tests) + console.log(this.formatTestHeader(test, { indent: ' ', mode: 'default' })); + } + } + private _printSummary(summary: string) { if (summary.trim()) console.log(summary);