# checkly pw-test - Checkly Docs

> Run Playwright tests with Checkly monitoring features

Source: https://www.checklyhq.com/docs/cli/checkly-pw-test/

---

Back to top
- Basic Usage Checkly Command Options
- Common Playwright Test Options

- Playwright Configuration vs. Applied Command Line Options
- Examples Validate smoke tagged tests from us-east-1
- Debug production issues
- Test from different locations
- Run critical tests only
- Run tests in multiple browsers
- Run a specific test file

- Key Features
- Cancelling a run
- Related Commands

CLI Commands

# checkly pw-test

Run Playwright tests with Checkly monitoring features

Available since CLI v6.1.0.

The `checkly pw-test` command runs Playwright tests on Checkly’s cloud infrastructure and supports standard Playwright CLI arguments.
This command records test sessions by default.

Prerequisites

Before using `checkly pw-test`, ensure you have:

- An initialized Checkly CLI project

- Valid Checkly account authentication (run `npx checkly login` if needed)

- Playwright tests in your project

- A `playwright.config.ts` or `playwright.config.js` file.

## Basic Usage

Use `--` to separate Checkly flags from Playwright test options.
Terminal

```
npx checkly pw-test [checkly options] -- [playwright options]
```

- Checkly Command Options
- Playwright Test Options

Define `checkly pw-test` specific options before the `--` separator: Option Required Description

`--config` - The Checkly CLI configuration file. If not passed, uses the `checkly.config.ts|js` file in the current directory.

`--create-check` - Create a Checkly check from the Playwright test.

`--detach, -d` - Start the checks in the cloud and exit after printing the test session ID, without waiting for results.

`--env, -e` - Env vars to be passed to the test run. Default: []

`--env-file` - dotenv file path to be passed. For example `--env-file="./.env"`

`--include, -i` - File patterns to include when bundling the test project (e.g., `"utils/**/*"`). Can be repeated.

`--install-command` - Override the command used to install dependencies before running tests.

`--location, -l` - The location to run the checks at.

`--private-location` - The private location to run checks at.

`--[no-]record` - Record test results in Checkly as a test session with full logs, traces and videos.

`--refresh-cache` - Force a fresh install of dependencies and update the cached version.

`--reporter` - One or more custom reporters for the test output. Supports comma-separated values and repeated flags.

`--[no-]stream-logs` - Stream logs from the test run to the console. Default: `true`.

`--test-session-name` - A name to use when storing results in Checkly

`--timeout` - A timeout (in seconds) to wait for each check to make progress once it starts running: report a retry attempt or its result. Checks that have not started yet get up to 900 additional seconds for server-side scheduling.

`--verbose` - Always show the full logs of the checks.

Define Playwright test runner flags after the `--` separator: Option Required Description

`--project` - Select Playwright projects

`--grep` - Filter tests by pattern

`--grep-invert` - Exclude tests by pattern

The `--reporter` and `--headed` options are not supported. Find more Playwright options in the [Playwright test runner docs](https://playwright.dev/docs/test-cli).

### Checkly Command Options

string

Specify a configuration file to use instead of the `checkly.config.ts` or `checkly.config.js` in the current directory. **Usage:** Terminal

```
npx checkly pw-test --config="./checkly.staging.config.ts"
```

boolean

Add a new [Playwright Check Suite](https://www.checklyhq.com/docs/detect/synthetic-monitoring/playwright-checks/overview) with your Playwright configuration to your `checkly.config`. **Usage:** Terminal

```
npx checkly pw-test --create-check
```

**Examples:** Running this command: Terminal

```
npx checkly pw-test --create-check -- --project="Mobile Chrome" --grep="@critical"
```

Adds a new Playwright Check Suite to your `checkly.config.ts`: checkly.config.ts

```
import { defineConfig } from 'checkly'
const config = defineConfig({
projectName: "Playwright Project",
logicalId: "playwright-project",

checks: {
playwrightConfigPath: "./playwright.config.ts",
playwrightChecks: [
{
logicalId: "playwright-check-project-mobile-chrome-grep-critical",
name: 'Playwright Test: "--project=Mobile Chrome" --grep=@critical',
testCommand:
'npx playwright test "--project=Mobile Chrome" --grep=@critical',
locations: ["eu-central-1"],
frequency: 10,
},
],
},
})
```

If there’s no existing `checkly.config.ts` file, the `--create-check` option will create one. `--create-check` doesn’t run your tests. Run `npx checkly deploy` to deploy the new check. Use `--frequency, -f` to set its frequency in minutes: `1`, `2`, `5`, `10` (default), `15`, `30`, `60`, `120`, `180`, `360`, `720` or `1440`.

boolean

default: "false"

Start the checks in the cloud and exit as soon as they’re scheduled. The CLI prints the test session ID and doesn’t wait for results. Get the results later with `checkly test-sessions get `. `--detach` can’t be combined with the `json` or `github` reporters. **Usage:** Terminal

```
npx checkly pw-test --detach
```

string[]

Pass environment variables to the test run. Can be specified multiple times to set multiple variables. **Usage:** Terminal

```
npx checkly pw-test --env API_KEY=123 --env BASE_URL=https://example.com
npx checkly pw-test -e NODE_ENV=production -e DEBUG=true
```

string

Load environment variables from a dotenv file. **Usage:** Terminal

```
npx checkly pw-test --env-file="./.env"
```

string[]

File patterns to include when bundling the test project. Use this to add files that aren’t automatically detected as dependencies, such as fixtures, helpers, or assets referenced at runtime. Can be specified multiple times to include multiple patterns. If not provided, falls back to the `checks.include` value in your `checkly.config`. **Usage:** Terminal

```
npx checkly pw-test --include="utils/**/*"
npx checkly pw-test -i="fixtures/**/*" -i="data/*.json"
```

string

Override the command used to install dependencies before running tests. By default, Checkly uses the install command of the package manager your project uses, for example `npm install --no-save` for npm. Use this to customize the install step, for example to skip lifecycle scripts or use a different package manager. **Usage:** Terminal

```
npx checkly pw-test --install-command='npm install --no-scripts'
npx checkly pw-test --install-command='pnpm install --frozen-lockfile'
```

string

Specify the geographic location where the checks should run. This determines which Checkly data center executes your tests. **Usage:** Terminal

```
npx checkly pw-test --location="us-east-1"
npx checkly pw-test -l="eu-west-1"
```

string

Run checks at a specific private location. Private locations allow you to test internal applications or services behind a firewall. **Usage:** Terminal

```
npx checkly pw-test --private-location="office-network"
npx checkly pw-test --private-location="staging-vpc"
```

boolean

default: "false"

Force a fresh install of dependencies and update the cached version. Use this when you’ve changed your project’s dependencies and need Checkly to pick up the latest versions instead of using the cache from a previous run. **Usage:** Terminal

```
npx checkly pw-test --refresh-cache
```

boolean

The `pw-test` automatically records your test results as a [test session](https://www.checklyhq.com/docs/detect/testing/overview) with full logs, traces, and videos. Use `--no-record` to disable recording. **Usage:** Terminal

```
npx checkly pw-test --record
npx checkly pw-test --no-record
```

string[]

One or more custom reporters for the test output. Options: `list`, `dot`, `ci`, `github`, `json`. You can combine multiple reporters by passing multiple `--reporter` flags or using a comma-separated list. **Usage:** Terminal

```
npx checkly pw-test --reporter="json"
npx checkly pw-test --reporter="github"
```

**Examples:** Terminal

```
# Multiple reporters using comma-separated values
npx checkly pw-test --reporter list,json

# Multiple reporters using repeated flags
npx checkly pw-test --reporter list --reporter json
```

boolean

default: "true"

Logs appear in real time as tests run. **Usage:** Terminal

```
npx checkly pw-test --stream-logs
```

string

Provide a custom name for the test session when storing results in Checkly. This helps identify and organize test runs. **Usage:** Terminal

```
npx checkly pw-test --test-session-name="Release v1.2.3 tests"
npx checkly pw-test --test-session-name="Daily regression suite"
```

number

default: "1200"

A timeout (in seconds) to wait for each check to make progress once it starts running: report a retry attempt or its result. Checks that have not started yet get up to 900 additional seconds for server-side scheduling. The timer restarts whenever a check starts running and whenever it reports a failed attempt that will be retried, so a check that retries several times can take longer than this value in total. The timeout only ends the wait when a check stops reporting progress. Checkly can stagger the start of checks in large test sessions by up to 900 seconds. If a check still has not started within this value plus that allowance, the CLI reports that the check did not start. That usually means a problem on Checkly’s side: check [the status page](https://is.checkly.online/) or contact support. When the CLI stops waiting for a check, whether it stopped making progress or never started, it reports the check as timed out rather than failed: the CLI did not receive a result, and the check may still run and pass in Checkly. Reporters mark it with ⏱ (`T` in the `dot` reporter) and count it as timed out in the summary, and the `json` reporter gives it `"result": "Timed out"`. The run still exits with code 1. **Usage:** Terminal

```
npx checkly pw-test --timeout="300"
npx checkly pw-test --timeout="1200"
```

boolean

Show full logs for every check, including passing ones. **Usage:** Terminal

```
npx checkly pw-test --verbose
```

### Common Playwright Test Options

The `pw-test` command reuses your `playwright.config` settings. To overwrite these values from the command line, [Playwright Check Suites](https://www.checklyhq.com/docs/detect/synthetic-monitoring/playwright-checks/overview) supports most [Playwright test runner options](https://playwright.dev/docs/test-cli).
string

Select specific Playwright projects to run. This allows you to run only a subset of your configured projects from your Playwright configuration. **Usage:** Terminal

```
npx checkly pw-test -- --project="chromium"
npx checkly pw-test -- --project="firefox"
```

You can only run projects specified in your `playwright.config` file.

string

Filter tests to run based on a pattern match against test titles. Only tests matching the pattern will be executed. **Usage:** Terminal

```
npx checkly pw-test -- --grep="@smoke"
npx checkly pw-test -- --grep="login|authentication"
```

string

Exclude tests from running based on a pattern match against test titles. Tests matching the pattern will be skipped. **Usage:** Terminal

```
npx checkly pw-test -- --grep-invert="@slow"
npx checkly pw-test -- --grep-invert="flaky|unstable"
```

## Playwright Configuration vs. Applied Command Line Options

[Playwright Check Suites](https://www.checklyhq.com/docs/detect/synthetic-monitoring/playwright-checks/overview) and the `pw-test` command read and parse your existing `playwright.config` to apply your configuration.
To differentiate between your local testing setup and the Checkly monitoring environment, you can rely on the set `CI` environment variable or override specific settings using command line options.
playwright.config.ts

```
export default defineConfig({
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
use: {
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
// ...
]
});
```

If you run `npx checkly pw-test` without additional arguments, the test suite will:

- run with `2` retries

- use `1` worker

- run all defined projects including `chromium`

All these options can be further customized by passing command line arguments to `pw-test`.
Terminal

```
# Run with 4 workers, only in chromium, and 3 retries
npx checkly pw-test -- --workers=4 --project="chromium" --retries=3
```

## Examples

### Validate smoke tagged tests from `us-east-1`

Terminal

```
npx checkly pw-test --location="us-east-1" -- --grep="@smoke"
```

### Debug production issues

Terminal

```
npx checkly pw-test --verbose -- tests/checkout.spec.ts
```

### Test from different locations

Terminal

```
npx checkly pw-test --location="ap-southeast-1"
npx checkly pw-test --location="eu-west-1"
```

### Run critical tests only

Terminal

```
npx checkly pw-test --env ENVIRONMENT=production -- --grep="@critical"
```

### Run tests in multiple browsers

Terminal

```
npx checkly pw-test -- --project=chromium --project=firefox
```

### Run a specific test file

Terminal

```
npx checkly pw-test -- test.spec.ts
```

## Key Features

- Your Playwright configuration applies automatically (traces, videos, screenshots)

- Test sessions are recorded by default with full logs, traces, and videos

- View all artifacts in Checkly’s UI

## Cancelling a run

Available in CLI v8.0.0+.

Cancellation is available only for recorded test sessions.
Press Ctrl + C during a `checkly pw-test` run to cancel the test session. The CLI keeps running to report the cancelled results; press Ctrl + C again to exit immediately without waiting. To start checks without waiting for them, use `--detach`. The CLI then exits as soon as the checks are scheduled, and the checks keep running in the cloud.
See [Cancellation](https://www.checklyhq.com/docs/concepts/cancellation) for the full flow.

## Related Commands

- [`checkly test`](https://www.checklyhq.com/docs/cli/checkly-test) - Test your setup before deployment

- [`checkly deploy`](https://www.checklyhq.com/docs/cli/checkly-deploy) - Deploy your Checkly configuration

Was this page helpful?

[Suggest edits](https://github.com/checkly/docs/edit/main/cli/checkly-pw-test.mdx)[Raise issue](https://github.com/checkly/docs/issues/new?title=Issue%20on%20docs&body=Path:%20/cli/checkly-pw-test)

[checkly members Previous](https://www.checklyhq.com/docs/cli/checkly-members)[checkly rca Next](https://www.checklyhq.com/docs/cli/checkly-rca)

[x](https://x.com/checklyhq)[github](https://github.com/checkly)[linkedin](https://linkedin.com/company/checkly)

[Powered by This documentation is built and hosted on Mintlify, a developer documentation platform](https://www.mintlify.com/?utm_campaign=poweredBy&utm_medium=referral&utm_source=checkly-422f444a)
