From f570928df4569c775033929d56a9ddf23a366df4 Mon Sep 17 00:00:00 2001 From: Axmin Shrestha <56112475+ax-sh@users.noreply.github.com> Date: Tue, 3 Dec 2024 06:58:09 +0545 Subject: [PATCH] test: add test for portfolio screenshot functionality --- __test__/puppet.spec.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/__test__/puppet.spec.ts b/__test__/puppet.spec.ts index 17a4a91..1b20245 100644 --- a/__test__/puppet.spec.ts +++ b/__test__/puppet.spec.ts @@ -31,6 +31,19 @@ test.describe("Playwright Browser Testing", () => { .catch(() => false); expect(exists).toBe(true); }); + test("should take a portfolio screenshot", async ({ page }) => { + const screenshotLocalFilePath = path.join(__dirname, "portfolio.png"); + const url = "https://ax-sh.github.io/"; + await page.goto(url); + await page.screenshot({ path: screenshotLocalFilePath }); + // Optionally check the file existence + const fs = await import("node:fs/promises"); + const exists = await fs + .access(screenshotLocalFilePath) + .then(() => true) + .catch(() => false); + expect(exists).toBe(true); + }); test("should download a pdf", async ({ page }) => { const pdfLocalFilePath = path.join(__dirname, "output.pdf"); const core = await import("../api/core");