Skip to content

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

fix(junit reporter): embedding attachments on report didnt work for tests outside root folder (#15359)

Sergio Freire71c08a5dcf66
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) {
}
}