Skip to content

Commit

Permalink
test(core): add test for example.com page title
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-sh committed Dec 2, 2024
1 parent cc116f1 commit 26ac743
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
18 changes: 18 additions & 0 deletions api/core/core.test.ts
Original file line number Diff line number Diff line change
@@ -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");
});
11 changes: 11 additions & 0 deletions api/core/core.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export async function downloadPDF() {
// const cloud = require("@sparticuz/chromium");
// // biome-ignore lint/style/useSingleVarDeclarator: <explanation>
// 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";
12 changes: 1 addition & 11 deletions api/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
export async function downloadPDF() {
// const cloud = require("@sparticuz/chromium");
// // biome-ignore lint/style/useSingleVarDeclarator: <explanation>
// 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";
2 changes: 1 addition & 1 deletion api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 26ac743

Please sign in to comment.