Skip to content

Commit

Permalink
💚 Compare PDFs only under Chromium
Browse files Browse the repository at this point in the history
There are slight rendering differences between
that and Firefox that otherwise make the
comparison fail.
  • Loading branch information
foosel committed May 25, 2024
1 parent 81ae83b commit 28deb76
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/specs/generate-pdf.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test.beforeEach(async ({page, testPdf}) => {
await expect(page.locator("#generate")).toBeEnabled();
});

test("Simple PDF generation", async ({page, testPdf}) => {
test("Simple PDF generation", async ({page, testPdf}, testInfo) => {
// generate PDF
await page.locator("#generate").click();

Expand All @@ -42,15 +42,18 @@ test("Simple PDF generation", async ({page, testPdf}) => {
expect(download.url()).toContain("blob:");
expect(download.suggestedFilename()).toMatch(/.pdf$/i);

let result;
try {
result = await pdfCompare(await download.path(), testPdf.outputPath);
} catch (error) {
result = error;
if (testInfo.project === "chromium") {
// compare PDFs, but only in Chrome for now due to different rendering in Firefox
let result;
try {
result = await pdfCompare(await download.path(), testPdf.outputPath);
} catch (error) {
result = error;
}
console.log("Result:", result);
expect(result.message).toBeUndefined();
expect(result.status).toBe("passed")
}
console.log("Result:", result);
expect(result.message).toBeUndefined();
expect(result.status).toBe("passed")

// cleanup
await download.delete();
Expand Down

0 comments on commit 28deb76

Please sign in to comment.