Standalone projects using @testrelic/playwright-analytics for navigation timelines, API tracking, network stats, and HTML reports.
| Example | Type | Targets | What it demonstrates |
|---|---|---|---|
| api-testing | API only | JSONPlaceholder API | CRUD, chaining, assertions, config options, error handling |
| unified-testing | E2E + API | Wikipedia + JSONPlaceholder | Browser + API in the same test |
| wikipedia | E2E | en.wikipedia.org | Homepage, search, navigation, media-heavy pages |
| flipkart | E2E | flipkart.com | Homepage, search, product pages, categories |
| E2E | google.com | Homepage, search, results navigation | |
| amazon | E2E | amazon.com | Single-test multi-page crawl (timeline navigations) |
cd playwright/api-testing # or any other example under this folder
npm install
npx playwright testFor browser-based examples:
cd playwright/wikipedia # or flipkart, google, amazon, unified-testing
npm install
npx playwright install chromium
npx playwright testEach example uses @testrelic/playwright-analytics ^2.7.0 with a cloud block in playwright.config.ts (apiKey: process.env.TESTRELIC_API_KEY, upload: 'both', artifact limits). Local JSON/HTML reports still run when no key is set.
Staging vs production: @testrelic/core applies process.env.TESTRELIC_API_KEY and process.env.TESTRELIC_CLOUD_ENDPOINT last when merging cloud config, so they override playwright.config.ts and .testrelic/testrelic-config.json. If both TESTRELIC_STAGE_API_KEY and TESTRELIC_API_KEY are in .env, production would always win for the key. Each playwright.config.ts calls scripts/apply-testrelic-staging-env.mjs after dotenv.config() so that:
- A non-empty
TESTRELIC_STAGE_API_KEYis copied ontoTESTRELIC_API_KEY. TESTRELIC_CLOUD_ENDPOINTis set toTESTRELIC_STAGE_CLOUD_ENDPOINTwhen that variable is non-empty; otherwise it defaults tohttps://stage.testrelic.ai/api/v1(staging API — production remainshttps://platform.testrelic.ai/api/v1in committed.testrelicwhen you are not using a stage key). See.env.example.
playwright.config.ts loads ../../.env from the repository root (via dotenv) before that step. New VS Code / Cursor integrated terminals also load that file via .vscode/settings.json.
- Create or copy an API key from the TestRelic dashboard (Settings → API Keys).
- Set
TESTRELIC_API_KEYfor production, or for staging setTESTRELIC_STAGE_API_KEY(shell, CI, or repo-root.env). Optionally setTESTRELIC_STAGE_CLOUD_ENDPOINTto override the default staging APIhttps://stage.testrelic.ai/api/v1. - Each project has a committed
.testrelic/testrelic-config.jsontemplate with"apiKey": "$TESTRELIC_API_KEY"and a distincttestrelic-repo.nameper example so runs show up separately in the cloud UI.
Optional tuning: adjust cloud.upload, cloud.uploadArtifacts, cloud.artifactMaxSizeMb, or cloud.timeout in playwright.config.ts (see the package README). Advanced: npx testrelic merge … and npx testrelic serve … are documented on npm for sharded runs and large local reports.
See the repository root README for broader reporter option tables.