From 71c08a5dcf66ffe6b4e7be12192d8db4615a59b6 Mon Sep 17 00:00:00 2001 From: Sergio Freire Date: Tue, 5 Jul 2022 18:35:14 +0100 Subject: [PATCH] fix(junit reporter): embedding attachments on report didnt work for tests outside root folder (#15359) --- packages/playwright-test/src/reporters/junit.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/playwright-test/src/reporters/junit.ts b/packages/playwright-test/src/reporters/junit.ts index ec13e87e9d..32eaa21b78 100644 --- a/packages/playwright-test/src/reporters/junit.ts +++ b/packages/playwright-test/src/reporters/junit.ts @@ -191,11 +191,10 @@ class JUnitReporter implements Reporter { if (!attachment.path) continue; try { - const attachmentPath = path.relative(this.config.rootDir, attachment.path); - if (fs.existsSync(attachmentPath)) - contents = fs.readFileSync(attachmentPath, { encoding: 'base64' }); + if (fs.existsSync(attachment.path)) + contents = fs.readFileSync(attachment.path, { encoding: 'base64' }); else - systemErr.push(`\nWarning: attachment ${attachmentPath} is missing`); + systemErr.push(`\nWarning: attachment ${attachment.path} is missing`); } catch (e) { } }