Browser checks allow you to monitor critical parts of your services, using Node.js' Playwright and @playwright/test APIs to run headless browsers for end-to-end testing.
It allows you to automate the Chromium browser using a single simple API. Use the powerful @playwright/test API to automate tests ran periodically. Typescript support.
You probably use sensitive information in your code base, and it is preferrable to use environment variables. You will find them below the code editor, in your browser check settings.
To access them, reference them in your code using standard Node.js syntax: process.env.ENV_VAR.
When creating a browser check, the Double Check setting is enabled by default. Upon failure, it will retry a second run right away to confirm a failed check.
This runtime version 2023.04 uses Node 16.x with a specific set of widely used libraries such as lodash, moment or axios.
The version of Node we use is 16x.
The full list of packages you can use are:
Each browser check has a global timeout of 2 minutes for the entire run. By default, individual tests have a 30-second timeout as configured by Playwright. You can extend this per-test timeout using:
test.setTimeout(120_000); // 2 minutes in milliseconds
Browser check logs, including those related to outages, are stored indefinitely and can be accessed at any time.
import { test, expect } from '@playwright/test';
test.beforeEach(async ({ page }) => {
await page.goto('https://app.acme.com/login');
await page.locator('input[type="text"]').type(process.env.EMAIL);
await page.locator('input[type="password"]').type(process.env.PASSWORD);
await page.getByRole('button', { name: 'Sign in', exact: true }).click();
});
test('has title', async ({ page }) => {
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Acme/);
});
test('is logged in', async ({ page }) => {
const content = page.locator('#project-id');
await expect(content).toHaveText('project_12345');
});