From 28deb76d21f1776a8ad4f595e4719ed813dc4bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Sat, 25 May 2024 19:06:56 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20Compare=20PDFs=20only=20under=20?= =?UTF-8?q?Chromium?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are slight rendering differences between that and Firefox that otherwise make the comparison fail. --- tests/specs/generate-pdf.spec.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/specs/generate-pdf.spec.js b/tests/specs/generate-pdf.spec.js index 4c57a2b..ff927f7 100644 --- a/tests/specs/generate-pdf.spec.js +++ b/tests/specs/generate-pdf.spec.js @@ -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(); @@ -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();