Get Started

Install the @testrelic/playwright-analytics reporter and fixture in your Playwright project and produce structured analytics JSON in minutes.

TestRelic is free to use and published under the MIT license. Get up and running with @testrelic/playwright-analytics in minutes.

Appium / mobile testing

For Appium/WDIO setup, see the Appium Installation guide.

Prerequisites

  • Node.js ≥ 18
  • Playwright ≥ 1.35 (@playwright/test is a peer dependency and must be installed in the same project)
AI Prompt — Full setup
Install @testrelic/playwright-analytics in this project and set it up completely:

1. Run: npm install @testrelic/playwright-analytics
2. Open playwright.config.ts and add the TestRelic reporter to the reporter array:
   ['@testrelic/playwright-analytics', {
     outputPath: './test-results/analytics-timeline.json',
     includeStackTrace: true,
     includeCodeSnippets: true,
     includeNetworkStats: true,
   }]
3. In all test files that currently import from '@playwright/test', change the import
   to '@testrelic/playwright-analytics/fixture' so navigation is tracked automatically.

Keep the existing 'list' reporter if it is already there. Do not change any test logic.
AI Prompt — API testing setup
Set up @testrelic/playwright-analytics for API testing in this project:

1. Install: npm install @testrelic/playwright-analytics
2. Update playwright.config.ts to include the reporter with trackApiCalls: true,
   captureRequestBody: true, captureResponseBody: true.
3. In my API test files, extend the base test fixture using testRelicApiFixture:

   import { test as base } from '@playwright/test';
   import { testRelicApiFixture } from '@testrelic/playwright-analytics/api-fixture';
   import { expect } from '@testrelic/playwright-analytics/fixture';
   const test = base.extend(testRelicApiFixture);

Show me the updated config and one example test file.

Troubleshooting

SymptomWhat to try
No report after the runConfirm the reporter array in playwright.config.ts includes @testrelic/playwright-analytics and that the outputPath directory is writable.
No analytics-timeline.json fileThe single JSON file is written in reportMode: 'embedded'. The default streaming mode writes test-results/.testrelic-report/ instead.
Cannot find module '@testrelic/playwright-analytics/fixture'Run npm install @testrelic/playwright-analytics in the same package where Playwright runs.
ERR_REQUIRE_ESM … fixture.jsYour tests compile as CommonJS. Run them as ESM, or import from @testrelic/playwright-analytics/fixture/cjs (and .../api-fixture/cjs).
ℹ TestRelic: No API key configured. Running in local mode.Expected without TESTRELIC_API_KEY — local reports are still written; only cloud upload is skipped.

Next steps

Was this page helpful?

On this page