Skip to main content
For information on creating and managing environment variables and secrets (including the difference between variables and secrets, inheritance, and where to set them), see the Environment Variables documentation.

Built-in variables available in Playwright Check Suites

Checkly sets the following environment variables on every Playwright Check Suite run:
VariableDescription
CHECKLYSet to 1 for all check runs executed by Checkly.
Useful to distinguish Checkly runs from local runs.
CHECKLY_RUN_SOURCEIndicates how the check was triggered.
Useful to customize the nature of your test depending on how it is run.
See CHECKLY_RUN_SOURCE values below.
CISet to 1 for CLI runs (npx checkly test or npx checkly trigger) and deployment-triggered checks.
ACCOUNT_IDThe UUID of the Checkly account.
CHECK_NAMEThe name of the check.
CHECKLY_CHECK_IDThe UUID of the check.
CHECKLY_REGIONThe region where the check was executed.

CHECKLY_RUN_SOURCE values

ValueDescription
CLI_DEPLOYUsed for the first run of Checks deployed using npx checkly deploy.
DEPLOYMENTUsed for Check runs triggered as part of a CI/CD deployment.
GROUP_RUN_ALLUsed for Check runs triggered from a Group’s edit screen, by clicking the “Run all checks” button.
SCHEDULE_NOWUsed for Check runs triggered manually by clicking “Schedule now” in the webapp.
SCHEDULERUsed for Check runs triggered as part of their regular schedule.
TEST_NO_RECORDUsed for Check runs triggered by the npx checkly test CLI command.
TEST_RECORDUsed for Check runs triggered by the npx checkly test --record or npx checkly pw-test CLI commands.
TRIGGER_APIUsed for Check runs triggered by the API.
TRIGGER_NO_RECORDUsed for Check runs triggered by the npx checkly trigger CLI command.
TRIGGER_RECORDUsed for Check runs triggered by the npx checkly trigger --record CLI command.

Use built-in variables

Common ways to use Checkly’s built-in environment variables:

Adjust behavior based on trigger type

Set different behavior for scheduled runs versus manual triggers:
import { test } from '@playwright/test';

test('API health check', async ({ request }) => {
  const isScheduledRun = process.env.CHECKLY_RUN_SOURCE === 'SCHEDULER';

  // Use shorter timeout for scheduled runs
  const timeout = isScheduledRun ? 5000 : 30000;

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

  // ... assertions
});

Configure Playwright based on environment

Adjust your Playwright configuration to always record traces on Checkly. In your playwright.config.ts, use the CHECKLY variable to identify it’s from Checkly.
playwright.config.ts
import { defineConfig } from '@playwright/test';

export default defineConfig({

  use: {
    // Always trace in Checkly to compare successful and failed runs, only on retry elsewhere
    trace: process.env.CHECKLY === '1' ? 'on' : 'on-first-retry',
  },
});

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');

  // Log region for debugging
  console.log(`Running in region: ${process.env.CHECKLY_REGION}`);

  // Region-specific assertions
  if (process.env.CHECKLY_REGION?.startsWith('eu-')) {
    // Expect EU-specific content, like a cookie banner
  }
});