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

This commit is contained in:
Sergio Freire 2022-07-05 18:35:14 +01:00 committed by GitHub
parent 2a805c1f1c
commit 71c08a5dcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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) {
}
}