diff --git a/api/core/core.test.ts b/api/core/core.test.ts index 6869837..13d34f2 100644 --- a/api/core/core.test.ts +++ b/api/core/core.test.ts @@ -1,11 +1,14 @@ import { describe, expect, it, test } from "bun:test"; const { chromium: playwright } = require("playwright-core"); +const chromium = require("@sparticuz/chromium"); test("Check the page title of example.com", async (t) => { + const executablePath: string = await chromium.executablePath(); + expect(executablePath).not.toBeEmpty(); const browser = await playwright.launch({ - // args: chromium.args, - // executablePath: await chromium.executablePath(), + args: chromium.args, // headless: chromium.headless, + // executablePath }); const context = await browser.newContext(); @@ -16,3 +19,11 @@ test("Check the page title of example.com", async (t) => { expect(pageTitle).toBe("Example Domain"); }); + +describe("PDF", () => { + it("should open browser", async () => { + const cloud = require("chrome-aws-lambda"); + const executablePath = await cloud.executablePath; + expect(executablePath).toEqual(null); + }); +}); diff --git a/api/core/index.ts b/api/core/index.ts index 8b83d73..8d119de 100644 --- a/api/core/index.ts +++ b/api/core/index.ts @@ -1 +1 @@ -export * from "./core"; \ No newline at end of file +export * from "./core"; diff --git a/api/core/puppet.test.ts b/api/core/puppet.test.ts new file mode 100644 index 0000000..d46b403 --- /dev/null +++ b/api/core/puppet.test.ts @@ -0,0 +1,23 @@ +import { expect, test } from "@playwright/test"; +test.describe("Playwright Browser Testing", () => { + test("should navigate to a page and check title", async ({ page }) => { + await page.goto("https://example.com"); + const title = await page.title(); + expect(title).toBe("Example Domain"); + }); + + // test('should find an element and check its text', async ({ page }) => { + // await page.goto('https://example.com'); + // const text = await page.locator('h1').innerText(); + // expect(text).toBe('Example Domain'); + // }); + // + // test('should take a screenshot', async ({ page }) => { + // await page.goto('https://example.com'); + // await page.screenshot({ path: 'screenshot.png' }); + // // Optionally check the file existence + // const fs = await import('fs/promises'); + // const exists = await fs.access('screenshot.png').then(() => true).catch(() => false); + // expect(exists).toBe(true); + // }); +}); diff --git a/bun.lockb b/bun.lockb index 0935435..1bb5095 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/docs/ref.md b/docs/ref.md new file mode 100644 index 0000000..cfc0ad5 --- /dev/null +++ b/docs/ref.md @@ -0,0 +1 @@ +https://playwright.dev/docs/running-tests diff --git a/package.json b/package.json index 03cf1c0..7ea9ec9 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "type": "module", "devDependencies": { "@biomejs/biome": "1.9.4", + "@playwright/test": "^1.49.0", "@types/bun": "latest" }, "peerDependencies": { @@ -12,7 +13,8 @@ "scripts": { "dev": "ntl dev", "format": "nr biome check --write", - "test": "bun test" + "test": "bun test", + "test:puppet": "nlx playwright test --headed puppet.test.ts" }, "dependencies": { "@netlify/functions": "^2.8.2",