Package Overview — Playwright
@testrelic/playwright-analytics is the SDK package for Playwright browser test analytics. It plugs into Playwright's reporter pipeline and the enhanced test fixture to capture rich test data with zero changes to your test logic.
What does this package provide?
| Export | Import path | What it does |
|---|---|---|
| Reporter class | @testrelic/playwright-analytics | Drop-in Playwright reporter — add to reporter array in playwright.config.ts |
| Enhanced fixture | @testrelic/playwright-analytics/fixture | Re-exports test and expect with automatic navigation tracking |
| API fixture | @testrelic/playwright-analytics/api-fixture | testRelicApiFixture for extending API test base fixtures |
| Merge utility | @testrelic/playwright-analytics/merge | mergeReports() — combine shard reports into one file |
How do I install it?
- For AI agents
- For Human
AI Prompt — Install and configure
Install @testrelic/playwright-analytics in this project and set it up:
1. Run: npm install --save-dev @testrelic/playwright-analytics
2. Add it to playwright.config.ts reporter array:
['@testrelic/playwright-analytics', {
outputPath: './test-results/analytics-timeline.json',
includeNetworkStats: true,
}]
3. In test files, change the import from '@playwright/test' to
'@testrelic/playwright-analytics/fixture'
Show me the updated config and one example test file.
npm install --save-dev @testrelic/playwright-analytics
Requirements: Node.js ≥ 18, Playwright ≥ 1.40
Quick configuration
Add the reporter to playwright.config.ts:
playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [
['list'],
['@testrelic/playwright-analytics', {
outputPath: './test-results/analytics-timeline.json',
includeNetworkStats: true,
}],
],
});
Switch the test fixture
In your test files, import from the TestRelic fixture instead of @playwright/test:
my-test.spec.ts
import { test, expect } from '@testrelic/playwright-analytics/fixture';
test('homepage loads', async ({ page }) => {
await page.goto('https://example.com');
await expect(page.locator('h1')).toBeVisible();
});
Navigation is tracked automatically — no other changes needed.
What's next?
Using Appium for mobile testing?
For the @testrelic/appium-analytics package, see the Appium Package Overview.
Loading chart…