2022-09-02 20:59:06 +00:00
|
|
|
/**
|
|
|
|
* This is a Playwright script Checkly generated for you based on your Vercel project.
|
|
|
|
* To learn more about Browser checks and Playwright visit: https://www.checklyhq.com/docs/browser-checks
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Create a Chromium browser
|
2022-09-08 22:04:32 +00:00
|
|
|
const { chromium } = require("playwright");
|
2022-09-02 20:59:06 +00:00
|
|
|
|
|
|
|
// Checkly supports top level await, but we wrap your code in an async function so you can run it locally too.
|
2022-09-08 22:04:32 +00:00
|
|
|
async function run() {
|
|
|
|
const browser = await chromium.launch();
|
|
|
|
const page = await browser.newPage();
|
2022-09-02 20:59:06 +00:00
|
|
|
|
|
|
|
// If available, we set the target URL to a preview deployment URL provided by the ENVIRONMENT_URL created by Vercel.
|
|
|
|
// Otherwise, we use the Production URL.
|
2022-09-08 22:04:32 +00:00
|
|
|
const targetUrl = process.env.ENVIRONMENT_URL || "https://app.cal.com";
|
2022-09-02 20:59:06 +00:00
|
|
|
|
|
|
|
// We visit the page. This waits for the "load" event by default.
|
2022-09-08 22:04:32 +00:00
|
|
|
const response = await page.goto(targetUrl);
|
2022-09-02 20:59:06 +00:00
|
|
|
|
|
|
|
// If the page doesn't return a successful response code, we fail the check
|
|
|
|
if (response.status() > 399) {
|
2022-09-08 22:04:32 +00:00
|
|
|
throw new Error(`Failed with response code ${response.status()}`);
|
2022-09-02 20:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// We snap a screenshot.
|
2022-09-08 22:04:32 +00:00
|
|
|
await page.screenshot({ path: "screenshot.jpg" });
|
2022-09-02 20:59:06 +00:00
|
|
|
|
|
|
|
// We close the page and browser. This is needed for collecting accurate web vitals.
|
2022-09-08 22:04:32 +00:00
|
|
|
await page.close();
|
|
|
|
await browser.close();
|
2022-09-02 20:59:06 +00:00
|
|
|
}
|
|
|
|
|
2022-09-08 22:04:32 +00:00
|
|
|
run();
|