Checkly formatting
parent
4162d403e1
commit
293c2ffb86
|
@ -4,31 +4,31 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Create a Chromium browser
|
// Create a Chromium browser
|
||||||
const { chromium } = require('playwright')
|
const { chromium } = require("playwright");
|
||||||
|
|
||||||
// Checkly supports top level await, but we wrap your code in an async function so you can run it locally too.
|
// Checkly supports top level await, but we wrap your code in an async function so you can run it locally too.
|
||||||
async function run() {
|
async function run() {
|
||||||
const browser = await chromium.launch()
|
const browser = await chromium.launch();
|
||||||
const page = await browser.newPage()
|
const page = await browser.newPage();
|
||||||
|
|
||||||
// If available, we set the target URL to a preview deployment URL provided by the ENVIRONMENT_URL created by Vercel.
|
// 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.
|
// Otherwise, we use the Production URL.
|
||||||
const targetUrl = process.env.ENVIRONMENT_URL || 'https://app.cal.com'
|
const targetUrl = process.env.ENVIRONMENT_URL || "https://app.cal.com";
|
||||||
|
|
||||||
// We visit the page. This waits for the "load" event by default.
|
// We visit the page. This waits for the "load" event by default.
|
||||||
const response = await page.goto(targetUrl)
|
const response = await page.goto(targetUrl);
|
||||||
|
|
||||||
// If the page doesn't return a successful response code, we fail the check
|
// If the page doesn't return a successful response code, we fail the check
|
||||||
if (response.status() > 399) {
|
if (response.status() > 399) {
|
||||||
throw new Error(`Failed with response code ${response.status()}`)
|
throw new Error(`Failed with response code ${response.status()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We snap a screenshot.
|
// We snap a screenshot.
|
||||||
await page.screenshot({ path: 'screenshot.jpg' })
|
await page.screenshot({ path: "screenshot.jpg" });
|
||||||
|
|
||||||
// We close the page and browser. This is needed for collecting accurate web vitals.
|
// We close the page and browser. This is needed for collecting accurate web vitals.
|
||||||
await page.close()
|
await page.close();
|
||||||
await browser.close()
|
await browser.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
run()
|
run();
|
||||||
|
|
Loading…
Reference in New Issue