Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: do not print empty attachments in terminal (#12419)

Pavel Feldman96945ab0a2c5
diff --git a/packages/playwright-test/src/reporters/base.ts b/packages/playwright-test/src/reporters/base.ts
index 12c4d24910..cf6b38793e 100644
--- a/packages/playwright-test/src/reporters/base.ts
+++ b/packages/playwright-test/src/reporters/base.ts
@@ -250,6 +250,9 @@ export function formatFailure(config: FullConfig, test: TestCase, options: {inde
if (includeAttachments) {
for (let i = 0; i < result.attachments.length; ++i) {
const attachment = result.attachments[i];
+ const hasPrintableContent = attachment.contentType.startsWith('text/') && attachment.body;
+ if (!attachment.path && !hasPrintableContent)
+ continue;
resultLines.push('');
resultLines.push(colors.cyan(pad(` attachment #${i + 1}: ${attachment.name} (${attachment.contentType})`, '-')));
if (attachment.path) {