Learn how to use the pw-test command to run Playwright tests with Checkly monitoring. Convert your existing Playwright tests into scheduled monitors with a single command.
Run Playwright tests with Checkly monitoring features. Convert to a check suite once you’re ready to start monitoring.
npx checkly pw-test [checkly flags] -- [playwright flags]
Use --
to separate Checkly flags from Playwright flags.
The pw-test
command:
--create-check
# Single browser
npx checkly pw-test -- --project=chromium
# Multiple browsers
npx checkly pw-test -- --project=chromium --project=firefox
# Filter by tag
npx checkly pw-test --location="eu-west-1" --location="us-west-1" -- --grep="@smoke"
By default, pw-test
uses N.Virginia (us-east-1
) to run. Use any global location or private location.
Using pw-test
with the --create-check
flag will create a checkly.config.ts
file if it doesn’t exist, and add the new check, so that you can tweak the monitoring configuration for your check.
Each --create-check
call will append the check configuration to your configuration file. If you run it twice with the same configuration, it’ll create the same check twice.
# Run all tests in the "chromium" project every 10 minutes
npx checkly pw-test --create-check --frequency=10m -- --project=chromium
# Run all tests tagged critical every 5 minutes
npx checkly pw-test --create-check --frequency=5m --location=us-east-1 --location=eu-west-1 -- --grep="@critical"
# Run all tests from the "Mobile Chrome" project every 15 mins in default location
npx checkly pw-test --create-check --frequency=15m -- --project="Mobile Chrome" --grep="@mobile"
# Desktop browsers
npx checkly pw-test -- --project="Desktop Chrome" --project="Desktop Firefox"
# Mobile devices
npx checkly pw-test -- --project="Mobile Safari" --project="Iphone 14"
# All tests tagged smoke
npx checkly pw-test -- --grep="@smoke"
# Exclude flaky tagged tests
npx checkly pw-test -- --grep-invert="@flaky"
# Create a check with tests tagged critical that runs every 10 minutes
npx checkly pw-test --create-check --frequency=10m -- --grep="@critical"
Configure which artifacts are stored in your playwright.config.ts
:
use: {
trace: 'on', // Always capture traces
video: 'retain-on-failure', // Record videos on failure
screenshot: 'only-on-failure' // Take screenshots on failure
}
If you’d like different configuration for your checks, make sure to use the --trace <mode>
flag in the testCommand
section of your Playwright Check Suite.
import { defineConfig } from 'checkly'
const config = defineConfig({
logicalId: 'my-repo-name',
projectName: 'my-repo-name',
checks: {
playwrightConfigPath: './playwright.config.ts',
playwrightChecks: [
{
logicalId: 'myrepo', // tweak ID
name: 'myrepo: Chromium Playwright Tests', // tweak name
testCommand: 'npx playwright test --project=chromium --trace=on',//
locations: [
'eu-central-1', 'us-east-1' // add or change locations
],
frequency: 10, // a custom per-check frequency
},
],
},
cli: {
runLocation: 'us-east-1', // where test and pw-test will run
},
})
export default config
View all artifacts in Checkly’s UI after test runs in Test Sessions.
# Pass individual variables and run all tests tagged with "regression" into a check suite
npx checkly pw-test --env ENVIRONMENT_URL="https://staging.acme.com" -- --grep="@regression"
# Load env from file
npx checkly pw-test --env-file=".env.staging" -- --project=chromium
# Checkout flow
npx checkly pw-test --create-check --frequency=15m --location=us-east-1 -- --project="Desktop Chrome" --grep="checkout"
# Mobile experience
npx checkly pw-test --create-check --frequency=30m -- --project="iPhone-13" --grep="@mobile-critical"
All runs record automatically. You can add custom names:
npx checkly pw-test --test-session-name="Pre-deployment check" -- --project=chromium
@smoke
, @regression
, @critical
playwright.config.ts
Tests fail in Checkly but pass locally
Missing artifacts
on
in playwright.config.ts
testCommand
to set the flag trace=on
“Project not found” errors
playwright.config.ts