Native Playwright Reporter
Stream live Playwright results from your existing CI pipeline (or your laptop) straight to the Agnox dashboard — no Docker image required. Runs reported from CI are External CI runs; runs reported from a developer machine are Local runs, kept out of your quality metrics (see Local vs External CI runs).
Want Agnox to run the tests for you instead? See Agnox Hosted for how the two execution models compare.
Installation
npm install -D @agnox/playwright-reporter
# yarn
yarn add -D @agnox/playwright-reporter
# pnpm
pnpm add -D @agnox/playwright-reporter
Requires @playwright/test 1.40 or later and Node.js 18 or later. The package is published pre-built on npm — no build step is needed.
Configuration
import 'dotenv/config'must be the first line ofplaywright.config.tsif you load credentials from a local.envfile, so they exist when Playwright evaluates the reporter config.
import 'dotenv/config'; // ← MUST be first
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
// Attachments the reporter uploads (see "Artifacts" below)
screenshot: 'only-on-failure',
video: 'retain-on-failure',
trace: 'retain-on-failure',
},
reporter: [
['list'], // keep your existing reporters
['@agnox/playwright-reporter', {
// apiKey and projectId default to AGNOX_API_KEY and AGNOX_PROJECT_ID
apiKey: process.env.AGNOX_API_KEY,
projectId: process.env.AGNOX_PROJECT_ID,
// environment: 'qa', // 'development' | 'qa' | 'staging' | 'production'
// groupName: 'Nightly regression', // run group (automatic in GitHub Actions)
// runName: 'nightly suite', // label shown in the Dashboard
// uploadArtifacts: 'failed-only', // 'failed-only' (default) | 'all' | 'none'
// createCycle: true, // also create a Test Cycle for this run
// cycleId: '<cycle id>', // add this run to an existing Test Cycle
// ciOnly: true, // report only from CI, never from a laptop
// artifacts: { traces: false }, // keep traces (headers, cookies) on the machine
// dryRun: true, // write the payload to a file, send nothing
// debug: true, // log reporter activity to stderr
}],
],
});
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes* | AGNOX_API_KEY | Your Agnox API key. *Not needed for a dryRun. |
projectId | string | Yes* | AGNOX_PROJECT_ID | The Agnox project the run belongs to. *Not needed for a dryRun. |
strict | boolean | No | false | Throw at startup when apiKey or projectId is missing. By default the reporter warns once and your tests run without reporting. See Missing credentials. |
softFailQuarantined | boolean | No | AGNOX_SOFT_FAIL_QUARANTINED, else true | Exit CI green when every failed test is actively quarantined and Agnox marked the run passed. See Quarantine soft-fail. |
baseUrl | string | No | https://api.agnox.dev | The Agnox API URL. Not your application's URL — leave it unset. |
runName | string | No | In GitHub Actions: the job id (GITHUB_JOB), plus <current>/<total> when sharded, e.g. e2e 2/3 | Label for the run, shown in place of its raw id in the dashboard (also the Test Cycle name when createCycle is on). An empty string turns the GitHub Actions default off. |
environment | 'development' | 'qa' | 'staging' | 'production' | No | AGNOX_ENVIRONMENT, else 'production' | Environment recorded on the run. An unknown AGNOX_ENVIRONMENT value prints a warning and is reported as production. |
groupName | string | No | AGNOX_GROUP_NAME, else the GitHub Actions workflow run | Run group for the Dashboard's Grouped view. See Run groups. '' turns grouping off. |
uploadArtifacts | 'failed-only' | 'all' | 'none' | No | 'failed-only' | Which tests' screenshots, videos and traces are uploaded. See Artifacts. |
createCycle | boolean | No | false | Also create a Test Cycle for this run. |
cycleId | string | No | — | Add the run to an existing Test Cycle of the same project. Takes precedence over createCycle. |
ciOnly | boolean | No | false | Report only from CI. Outside CI the reporter does nothing and prints one line. Also enabled by AGNOX_CI_ONLY=true; AGNOX_REPORT=true overrides it. |
source | 'external-ci' | 'local' | No | detected | Overrides the detected source. 'external_ci' is accepted too. |
redactSecrets | boolean | No | true | Remove secrets (tokens, JWTs, auth headers, cookies, secret URL parameters) from everything sent. See Privacy & Redaction. |
redactPatterns | RegExp[] | No | — | Extra patterns to replace with [REDACTED]. |
enabled | boolean | No | true | false turns the reporter off: no request is made. |
skipLocalRuns | boolean | No | false | Don't report runs outside CI. Same as ciOnly. |
artifacts | boolean | { traces?, screenshots?, videos? } | No | true | Which kinds of attachment are uploaded. { traces: false } keeps traces local. |
context | { domSnapshot?, console?, network?, pageErrors?, logs? } | No | all true | Which failure context and output is sent. |
dryRun | boolean | No | false | Write the payload to a local file instead of sending it. |
dryRunOutput | string | No | <rootDir>/agnox-dry-run.json | Where the dry run writes. |
flushIntervalMs | number | No | 2000 | How often buffered events are sent. |
maxBatchSize | number | No | 50 | Events per batch before an early flush. |
debug | boolean | No | false | Log reporter activity to stderr. |
Missing credentials
If apiKey or projectId is missing (and neither AGNOX_API_KEY nor AGNOX_PROJECT_ID is set), the reporter prints one line and your tests run as usual, without reporting:
[agnox] Reporting disabled: missing AGNOX_API_KEY. Tests will run normally without Agnox reporting.
This keeps pull requests from forks, whose workflows get no secrets, green. To make a missing credential fail the run instead, set strict: true.
Finding your credentials
- API key: Settings → Profile → API Access → Generate New Key. The key is shown once — store it as a CI secret.
- Project ID: Settings → Run Settings → select your project → Execution Defaults.
How It Works
- When Playwright starts, the reporter opens a session with Agnox in its
onBegin. Playwright doesn't wait for this, so results of tests that start or finish first are held and sent, in order and with their original timing, as soon as the session exists. The first test of a run never shows up untitled. From v2.7.0 this ordering is built in: you don't need a wrapper reporter or aglobalSetupstep to make Playwright wait. If the session can't be created, the held results are dropped and the test run isn't delayed. - While tests run, results and log lines are sent in small batches every 2 seconds — they appear live in the dashboard.
- Screenshots, videos and traces of failed tests are uploaded in the background.
- When Playwright finishes, the run is closed with its final status.
Your tests run in your own CI or on your laptop, and the reporter doesn't upload your repository. It sends results, log lines, failure context and (by default) failed tests' attachments over HTTPS. See Security & Data Storage → for exactly what is sent and how long it is kept.
CI runs appear on the Dashboard under the External CI source filter, with the branch, commit, PR number and CI job link detected automatically on GitHub Actions, GitLab CI, Azure DevOps and Jenkins. Runs from other CI platforms are still External CI runs, without that context.
Local vs External CI runs
From v2.5.0 the reporter tells a developer machine from a CI pipeline, so debugging on your laptop never skews your project's metrics.
Detection. A run is an External CI run when any of these environment variables is set (to anything except an empty string, 0 or false): CI, GITHUB_ACTIONS, GITLAB_CI, JENKINS_URL, TF_BUILD, CIRCLECI, BITBUCKET_BUILD_NUMBER, BUILDKITE, TEAMCITY_VERSION, TRAVIS. Otherwise it is a Local run. Set source: 'external-ci' or source: 'local' to override the detection.
Local runs are excluded from every metric: Pass Rate and the other KPI cards, Stability Score, trend charts, flaky-test detection, auto-quarantine, failure clusters and Smart PR history. Their tests are still linked to your test cases, and their artifacts are uploaded as usual.
On the Dashboard, local runs carry a Local badge and are hidden from the default view. Pick Local under Execution source to see them. A brand-new project whose only runs are local shows them anyway, with a banner, so your first run from the Quick Start appears right away. Once the first CI or hosted run arrives, local runs leave the default view.
Quota. Local runs count toward your plan's External CI Runs, like CI runs.
Report only from CI
To stop local runs from being reported at all, turn on ciOnly:
['@agnox/playwright-reporter', {
apiKey: process.env.AGNOX_API_KEY!,
projectId: process.env.AGNOX_PROJECT_ID!,
ciOnly: true,
}],
or set AGNOX_CI_ONLY=true in your shell profile. Outside CI the reporter then prints one line and does nothing else:
[agnox] Skipped reporting: ciOnly / skipLocalRuns is on and this is not a CI run. Set AGNOX_REPORT=true to report this run.
To report one local run anyway (for example, to check your setup), run it with AGNOX_REPORT=true:
AGNOX_REPORT=true npx playwright test
ciOnly is off by default so that a first run from your laptop shows up in Agnox without extra configuration. skipLocalRuns: true is the same option under another name.
Upgrading from 2.4.x or earlier: older versions reported every run, laptop runs included, as External CI. Runs already recorded keep that source. Agnox servers that predate local runs accept 2.5.0 too: the reporter then records the run as External CI.
Run groups
Runs with the same group appear together in the Dashboard's Grouped view (switch Flat / Grouped above the list), and Search groups filters by it. The reporter picks the group in this order:
- the
groupNameoption; - the
AGNOX_GROUP_NAMEenvironment variable; - in GitHub Actions,
<workflow name> #<run number>, for exampleE2E #42(the run ID when there is no run number).
So every job and shard of one GitHub Actions workflow run is grouped without any configuration, and re-running failed jobs keeps the run number, so the re-run joins the same group. Set groupName: '' to turn grouping off. Names are cut to 128 characters, and secrets in them are redacted.
Server compatibility: reporter 2.7.0 sends
groupNameand acceptsenvironment: 'qa'. An Agnox server that does not knowgroupNamestill records the run, ungrouped (the reporter retries without it). Self-hosted servers must be upgraded before a run can useqa.
Test Cycles are opt-in
Runs are recorded as executions only, so CI does not flood the Test Cycles page. To also track a run as a Test Cycle:
createCycle: true— creates a new cycle named afterrunName; it appears on the CI / Automated tab and completes when the run finishes.cycleId: '<id>'— adds the run to an existing cycle in the same project; the cycle's summary is recounted from all its items.
An unknown cycleId, or one from another project, is rejected (400 / 404) before anything is recorded.
Upgrading from 2.1.x or earlier: older versions created a Test Cycle for every run. Pass
createCycle: trueto keep that behaviour.
Artifacts (Screenshots, Videos, Traces)
From v2.3.0 the reporter automatically uploads the files Playwright attaches to your tests. They appear in the run's Artifacts tab in the Investigation Hub — exactly like the artifacts of an Agnox Hosted run. Turn the attachments on in playwright.config.ts as usual (screenshot, video, trace — see the example above).
| Rule | Value |
|---|---|
| Which tests | 'failed-only' (default): failed and timed-out tests, including the failed attempts of a flaky test. Passing tests upload nothing. 'all' uploads every test's attachments; 'none' turns uploads off. |
| File types | .png, .jpg, .jpeg, .webp, .webm, .mp4, .zip (traces), .md, .txt, .json |
| Per file | 25 MB — larger files are skipped (visible with debug: true) |
| Per run | 150 MB in total |
| Storage | Uploads count toward your organization's storage. When the storage quota is used up, the reporter stops uploading for the rest of the run — test results are still reported. |
| Retention | Artifacts are kept as long as the run — see plan retention. |
Uploads run in the background, three at a time, while your tests run. When the run ends, pending uploads get at most 20 seconds.
CI Integration
# .github/workflows/e2e.yml
name: E2E Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npx playwright install --with-deps
- name: Run Playwright tests
env:
AGNOX_API_KEY: ${{ secrets.AGNOX_API_KEY }}
AGNOX_PROJECT_ID: ${{ secrets.AGNOX_PROJECT_ID }}
AGNOX_ENVIRONMENT: qa # optional: development, qa, staging or production (default)
run: npx playwright test
No reporter option is needed for any of this: apiKey, projectId and environment come from AGNOX_API_KEY, AGNOX_PROJECT_ID and AGNOX_ENVIRONMENT, and the run is grouped as E2E Tests #<run number> with every other job and shard of the workflow run (AGNOX_GROUP_NAME sets another name). On a pull request from a fork the secrets are empty, so the reporter warns once and the tests still run.
More CI examples: GitHub Actions & CI/CD →
Quarantine soft-fail
When a run fails only because of tests that are actively quarantined, Agnox marks it PASSED (see the Quality Gate), and from reporter 2.8.0 your CI job exits green too. The reporter returns { status: 'passed' } from onEnd and prints one line:
[Agnox] Soft-fail applied: 2 failed test(s) are actively quarantined. Overriding CI exit status to passed.
It is on by default. Turn it off with softFailQuarantined: false, or with AGNOX_SOFT_FAIL_QUARANTINED=false in the job's environment (the option wins over the variable). When it is off and Agnox passed the run, the reporter prints a note and the job keeps failing.
The exit status changes only when all of these hold:
- Playwright's own status is
failed. Atimedoutorinterruptedrun is never changed. - Agnox answered
POST /api/ingest/teardownwithin the reporter's 15-second budget withdata.status: 'PASSED'anddata.quarantineBypassed: true. - Playwright reported no error outside of tests (a spec file that failed to load, a failing
globalSetup). - Every test of the run (of the shard, when sharded) ran. A run that stopped early, for example at
maxFailures, keeps failing. Skipped andfixmetests count as run.
Fail-safe: if Agnox can't be reached, times out, refuses the request or answers with anything else (including an older Agnox server), the job keeps Playwright's failed status. A dryRun never changes it. With sharding, each shard is evaluated on its own failures.
Privacy & Redaction
From v2.6.0 the reporter removes secrets on your machine, before any request leaves it, and lets you keep whole kinds of data local.
Secret redaction (on by default)
Before sending, the reporter replaces these with [REDACTED]:
Authorization,Proxy-Authorization,Cookie/Set-Cookie,x-api-keyandx-auth-tokenheader values, andBearertokens;- JWTs (
eyJ…); - secret URL parameters, in the query string or the fragment:
token,key,api_key,password,secret,auth,access_token,client_secret, signatures (sig,X-Amz-Signature, …) and any name ending intoken,secretorpassword; - credentials in URLs (
https://user:password@host); NAME=valueand"name": "value"pairs whose name ends inpassword,secret,token,api_keyand the like;- common provider keys (GitHub, Stripe, AWS, OpenAI, Anthropic, Google, Slack, SendGrid) and PEM private keys;
- anything matching your own
redactPatterns.
Redaction covers log output (stdout/stderr), test errors, step titles, the failure context (page and console errors, page and request URLs, the DOM snapshot), the run name, CI repository and run URLs, text artifacts (error-context.md, .txt, .json) and the reporter's own debug output. It runs before anything is shortened, so a secret at a length limit is not cut in half and missed. Test titles and spec file names are not changed: run history and flaky-test detection depend on them.
['@agnox/playwright-reporter', {
apiKey: process.env.AGNOX_API_KEY,
projectId: process.env.AGNOX_PROJECT_ID,
redactPatterns: [/ACME-[0-9]{8}/, /internal-customer-id=\w+/], // optional, every match replaced
// redactSecrets: false, // turns the built-in rules off; redactPatterns still apply
}],
Agnox applies the same rules again when it receives the data, so runs from older reporter versions are redacted too before they are stored.
Traces, videos and screenshots cannot be redacted. They are binary files. A Playwright trace records every request with its headers, cookies and bodies. If your tests use real credentials, keep traces on the machine with
artifacts: { traces: false }.
Choosing what is sent
| Option | Effect |
|---|---|
enabled: false | The reporter does nothing: no request, no output. For example enabled: !!process.env.AGNOX_REPORT (opt-in) or enabled: process.env.TARGET_ENV !== 'production'. |
skipLocalRuns: true | Runs outside CI are not reported. Same as ciOnly; AGNOX_REPORT=true still forces reporting. |
artifacts: false | No attachment is uploaded. Results are still reported. |
artifacts: { traces: false } | Traces stay local; screenshots and videos are still uploaded. screenshots and videos work the same way. Kinds you leave out stay on. |
context: { domSnapshot: false } | No DOM snapshot: neither the ARIA snapshot nor Playwright's error-context.md (as context or as an artifact). Test ids are still sent. |
context: { console: false } | No browser console errors. |
context: { network: false } | No failed-request list. |
context: { pageErrors: false } | No uncaught page exceptions. |
context: { logs: false } | The test runner's stdout/stderr (console.log in tests) is not streamed. |
uploadArtifacts still decides which tests' attachments are uploaded; artifacts decides which kinds.
Dry run: audit the payload
['@agnox/playwright-reporter', { dryRun: true }],
With dryRun: true the reporter runs exactly as it would (capture, the options above, redaction, batching) but sends nothing. It writes every request it would have made to agnox-dry-run.json next to your Playwright config (or to dryRunOutput): the JSON body of each setup, event and teardown call, and a list of the artifacts it would upload, with their kind, size and, for text files, their redacted content. The API key is never written. A dry run needs no apiKey or projectId, so a security team can review the output before reporting is turned on. Add agnox-dry-run.json to your .gitignore.
Enabling Runtime Context (Recommended)
Import test and expect from the reporter instead of @playwright/test to upgrade AI Root Cause Analysis from log parsing to structured, failure-time diagnostics. At the moment a test fails, the reporter captures:
- the page URL and
<title>; - page errors and
console.error()messages; - failed network requests (
4xx/5xxor connection errors); - an ARIA snapshot of the page (capped at 8 KB);
- up to 50 test-id values on the page (your
testIdAttribute, defaultdata-testid), used for locator repair suggestions.
Passing tests have no overhead, and no test file changes — update the shared fixtures file your tests import from:
// tests/fixtures/base.ts ← a fixtures file, not a test file
- import { test, expect } from '@playwright/test';
+ import { test, expect } from '@agnox/playwright-reporter';
The exported test is a drop-in replacement: it adds an automatic fixture that runs for every test and attaches the captured context to the failure.
Zero-Crash Guarantee
Your test suite never fails because of this reporter.
- If
AGNOX_API_KEYorAGNOX_PROJECT_IDis missing, the reporter warns once and your tests run without reporting (fail-open). Setstrict: trueto make a missing credential an error instead. See Missing credentials. - If Agnox is unreachable or your credentials are wrong, the reporter becomes a no-op after one retry.
- A batch that fails to deliver is dropped; after two failures in a row the reporter stops sending for the rest of the run.
- Reporter errors are never thrown to Playwright.
- Finishing the run is capped: at most 20 seconds are added to your CI job.
The worst case is a run that does not appear in Agnox. Green builds stay green.
Filtering by Source
Use the Source filter on the Dashboard to tell runs apart:
- Agnox Hosted — runs executed in an Agnox container from your Docker image (see Agnox Hosted). They count toward your plan's Agnox Hosted Runs.
- External CI — runs reported by
@agnox/playwright-reporterfrom a CI pipeline. They count toward your plan's External CI Runs. - Local — runs reported by
@agnox/playwright-reporterfrom a developer machine. Hidden from All once the project has CI or hosted runs, excluded from every metric, and counted toward External CI Runs.
All shows hosted and External CI runs.
See Plans & Quotas →.
Troubleshooting
No data in the Dashboard
dotenv/configmust be the first line ofplaywright.config.tswhen credentials come from a.envfile.- Do not set
baseUrlto your application's URL. The reporter'sbaseUrlis the Agnox API (https://api.agnox.dev) and is already the default. Your app's URL goes in Playwright'suse.baseURL. - Temporarily set
debug: trueto see what the reporter is doing. - A run from your laptop is a Local run: once the project has CI or hosted runs, pick Local under Execution source to see it.
- If the reporter printed
Skipped reporting: ciOnly / skipLocalRuns is on,ciOnly,skipLocalRunsorAGNOX_CI_ONLY=trueis set: run withAGNOX_REPORT=trueto report this run.
Cannot find module '@agnox/playwright-reporter'
The package is not installed in the environment that runs Playwright. Make sure it is in your devDependencies (npm install -D @agnox/playwright-reporter) and that your CI runs npm ci before npx playwright test.
Screenshots or videos are missing from the Artifacts tab
- Check that Playwright actually produces them (
screenshot,video,traceinuse). - With the default
'failed-only', passing tests upload nothing. - Files over 25 MB, and files beyond 150 MB per run, are skipped; uploads also stop when your organization's storage is full.
- Upgrade to v2.3.0 or later:
npm install -D @agnox/playwright-reporter@latest.
Related
- Integrations Overview →
- Quick Start →
- Security & Data Storage →
- GitHub Actions & CI/CD →
- JUnit XML & Allure Report Ingestion → — for frameworks other than Playwright
- Release Readiness Gate → — gate a release on the runs this reporter sends
- PR Test Auditor → — catch
.only, new skips and weakened assertions in a pull request - Agnox Hosted →
- Docker Container Setup (Agnox Hosted) →