Get Started with the Free SDK
TestRelic is free to use and published under the MIT license. Get up and running with @testrelic/playwright-analytics in your Playwright project in minutes — either by asking your AI assistant to do it, or by following the manual steps yourself.
What do I need before I start?
- Node.js >= 18
- Playwright >= 1.35.0
- With AI Prompts
- Manual Steps
How do I set up TestRelic using an AI assistant?
Copy one of the prompts below and paste it into your AI coding assistant. Each prompt is self-contained and tells the AI exactly what to install and configure.
Full setup (one prompt, does everything)
Use this if you want the AI to handle the entire setup in one go:
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.
Step-by-step prompts (one at a time)
Use these if you prefer to guide the AI step by step.
Step 1 — Install the package:
Run the following in my project terminal:
npm install @testrelic/playwright-analytics
Step 2 — Configure the reporter:
Open playwright.config.ts and add @testrelic/playwright-analytics to the reporter array.
Use this configuration:
['@testrelic/playwright-analytics', {
outputPath: './test-results/analytics-timeline.json',
includeStackTrace: true,
includeCodeSnippets: true,
includeNetworkStats: true,
}]
Keep any existing reporters (like 'list'). Show me the updated file.
Step 3 — Switch the test fixture:
In my test files, replace:
import { test, expect } from '@playwright/test';
with:
import { test, expect } from '@testrelic/playwright-analytics/fixture';
This enables automatic navigation tracking. Do not change any test logic.
Step 4 — Run the tests:
Run my Playwright tests with:
npx playwright test
Then tell me where the analytics report was written.
Prompt for API testing setup
Use this if you are writing API-only tests (no browser):
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.
How do I install the package?
Install the TestRelic Playwright analytics package from npm:
npm install @testrelic/playwright-analytics
How do I add the reporter to my Playwright config?
Open playwright.config.ts and add the TestRelic reporter to the reporter array:
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [
['list'],
['@testrelic/playwright-analytics', {
outputPath: './test-results/analytics-timeline.json',
includeStackTrace: true,
includeCodeSnippets: true,
includeNetworkStats: true,
}],
],
});
How do I use the TestRelic fixture in my tests?
Import test and expect from @testrelic/playwright-analytics/fixture instead of the default Playwright import. This enables automatic navigation tracking with no other changes required:
import { test, expect } from '@testrelic/playwright-analytics/fixture';
test('homepage loads correctly', async ({ page }) => {
await page.goto('https://example.com');
await expect(page.locator('h1')).toBeVisible();
});
The fixture is fully compatible with Playwright's API — existing test logic does not need to change.
How do I run my tests?
Run your Playwright tests as you normally would:
npx playwright test
The JSON analytics report is written to ./test-results/analytics-timeline.json after the run completes.
What should I do next?
- Learn about the report structure
- Explore configuration options
- Check out examples