Skip to content

Commit

Permalink
fix(playwright): fix copyFile error (#104)
Browse files Browse the repository at this point in the history
Handle nested directories while copying files.
  • Loading branch information
gregberge authored Jan 10, 2024
1 parent 0d2a651 commit 047b76f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/playwright/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ class ArgosReporter implements Reporter {
await writeFile(path, body);
}

async copyFile(from: string, to: string) {
const dir = dirname(to);
if (dir !== this.uploadDir) {
await mkdir(dir, { recursive: true });
}
await copyFile(from, to);
}

getAutomaticScreenshotName(test: TestCase, result: TestResult) {
let name = test.titlePath().join(" ");
name += result.retry > 0 ? ` #${result.retry + 1}` : "";
Expand All @@ -98,7 +106,7 @@ class ArgosReporter implements Reporter {
this.uploadDir,
getAttachmentFilename(attachment.name),
);
await copyFile(attachment.path, path);
await this.copyFile(attachment.path, path);
return;
}

Expand All @@ -110,8 +118,8 @@ class ArgosReporter implements Reporter {
const path = join(this.uploadDir, `${name}.png`);
await Promise.all([
this.writeFile(path + ".argos.json", JSON.stringify(metadata)),
copyFile(attachment.path, path),
trace ? copyFile(trace.path, path + ".pw-trace.zip") : null,
this.copyFile(attachment.path, path),
trace ? this.copyFile(trace.path, path + ".pw-trace.zip") : null,
]);
return;
}
Expand Down

0 comments on commit 047b76f

Please sign in to comment.