diff --git a/api/core/core.test.ts b/api/core/core.test.ts new file mode 100644 index 0000000..6869837 --- /dev/null +++ b/api/core/core.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, it, test } from "bun:test"; +const { chromium: playwright } = require("playwright-core"); + +test("Check the page title of example.com", async (t) => { + const browser = await playwright.launch({ + // args: chromium.args, + // executablePath: await chromium.executablePath(), + // headless: chromium.headless, + }); + + const context = await browser.newContext(); + const page = await context.newPage(); + await page.goto("https://example.com"); + const pageTitle = await page.title(); + await browser.close(); + + expect(pageTitle).toBe("Example Domain"); +}); diff --git a/api/core/core.ts b/api/core/core.ts new file mode 100644 index 0000000..a6ba6a4 --- /dev/null +++ b/api/core/core.ts @@ -0,0 +1,11 @@ +export async function downloadPDF() { + // const cloud = require("@sparticuz/chromium"); + // // biome-ignore lint/style/useSingleVarDeclarator: + // const executablePath = await cloud.executablePath() + const { chromium } = require("playwright-core"); + + return { c: chromium }; +} + +export const cloud = require("chrome-aws-lambda"); +export const desc = "Api for pdf generation"; diff --git a/api/core/index.ts b/api/core/index.ts index a6ba6a4..8b83d73 100644 --- a/api/core/index.ts +++ b/api/core/index.ts @@ -1,11 +1 @@ -export async function downloadPDF() { - // const cloud = require("@sparticuz/chromium"); - // // biome-ignore lint/style/useSingleVarDeclarator: - // const executablePath = await cloud.executablePath() - const { chromium } = require("playwright-core"); - - return { c: chromium }; -} - -export const cloud = require("chrome-aws-lambda"); -export const desc = "Api for pdf generation"; +export * from "./core"; \ No newline at end of file diff --git a/api/index.ts b/api/index.ts index e5ac941..19c719d 100644 --- a/api/index.ts +++ b/api/index.ts @@ -4,7 +4,7 @@ import type { Handler } from "@netlify/functions"; export const handler: Handler = async (event, context) => { - const core = await import("../api/core"); + const core = await import("./core"); const data = await core.downloadPDF(); return { statusCode: 200,