Skip to main content
To create and manage environment variables and secrets, including inheritance and where to set them, see the Environment Variables documentation.

Built-in variables in Playwright Check Suites

Checkly sets the following environment variables on every Playwright Check Suite run:
VariableDescription
CHECKLYCheckly sets this to 1 for every Playwright Check Suite run. Use it to distinguish Checkly runs from local runs.
CHECKLY_RUN_SOURCEIdentifies what triggered the check run. Use it to adjust test behavior for schedules, manual triggers, deployments, or CLI runs. See CHECKLY_RUN_SOURCE values.
CICheckly sets this to 1 for CLI runs (npx checkly test or npx checkly trigger) and checks started by deployments.
ACCOUNT_IDThe UUID of the Checkly account.
CHECK_NAMEThe name of the check.
CHECKLY_CHECK_IDThe UUID of the check.
CHECKLY_REGIONThe region where Checkly ran the check.

CHECKLY_RUN_SOURCE values

ValueDescription
CLI_DEPLOYThe first run after npx checkly deploy.
DEPLOYMENTA CI/CD deployment started the run.
GROUP_RUN_ALLThe “Run all checks” action on the group’s edit screen started the run.
SCHEDULE_NOWThe “Schedule now” action in the web app started the run.
SCHEDULERThe regular check schedule started the run.
TEST_NO_RECORDnpx checkly test started the run.
TEST_RECORDnpx checkly test --record or npx checkly pw-test started the run.
TRIGGER_APIThe API started the run.
TRIGGER_NO_RECORDnpx checkly trigger started the run.
TRIGGER_RECORDnpx checkly trigger --record started the run.

Use built-in variables

Use Checkly’s built-in environment variables to tune test behavior for different run contexts.

Adjust behavior based on trigger type

Use different timeouts for scheduled runs and manual triggers:
import { test } from '@playwright/test';

test('API health check', async ({ request }) => {
  // Scheduled monitors should fail fast. Manual runs can wait longer for debugging.
  const isScheduledRun = process.env.CHECKLY_RUN_SOURCE === 'SCHEDULER';
  const timeout = isScheduledRun ? 5000 : 30000;

  const response = await request.get('https://api.example.com/health', {
    timeout,
  });

  // ... assertions
});

Configure Playwright by environment

Use the built-in CHECKLY environment variable in your playwright.config.ts to use different settings for Checkly runs and local development.
playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({
  // Run one worker in Checkly when tests share state or accounts.
  workers: process.env.CHECKLY === '1' ? 1 : undefined,
  use: {
    // Checkly runs against a public URL. Local runs use the dev server.
    baseURL: process.env.CHECKLY === '1'
      ? 'https://www.example.com'
      : 'http://localhost:3000',
  },
});
Playwright Check Suites record traces for successful and failed runs. Checkly uses these traces to show dedicated Network and Browser console sections, so you can compare requests, logs, and errors when you troubleshoot.
You can also adjust these settings for Checkly runs:
  • maxFailures: stop early during monitoring runs, for example after the first failure.
  • timeout: give tests more or less time in Checkly than during local development.
  • expect.timeout: tune assertion timeouts for production or staging environments.
  • retries: override Checkly’s default retry count if your suite needs a different policy.

Access region information

Use region information for debugging or region-specific behavior:
import { test } from '@playwright/test';

test('geo-specific content test', async ({ page }) => {
  await page.goto('https://example.com');

  // Include the region in logs to compare results across locations.
  console.log(`Running in region: ${process.env.CHECKLY_REGION}`);

  // Add assertions only for regions where the content should appear.
  if (process.env.CHECKLY_REGION?.startsWith('eu-')) {
    // Example: check for an EU-specific cookie banner.
  }
});