Record your first Playwright run
By the end of this tutorial, you’ll be able to open a run in TestPerch and see the outcome of a test you recognize. You’ll need an existing Playwright suite with a test you can run locally and a TestPerch project.
1. Install the reporter
Section titled “1. Install the reporter”Run this command in the package that contains your Playwright configuration.
pnpm add -D @testperch/playwrightKeep the existing @playwright/test installation. If your project uses npm, use npm install --save-dev @testperch/playwright.
2. Set the reporter key for this shell
Section titled “2. Set the reporter key for this shell”Open Onboarding in your project’s settings. A workspace owner or admin can generate a reporter key here. If the project is already reporting, use its existing key.
In Bash, run these lines and paste the key at the prompt. The prompt hides what you type.
read -rs -p 'Reporter key: ' TESTPERCH_API_KEYechoexport TESTPERCH_API_KEY3. Add TestPerch alongside your existing reporters
Section titled “3. Add TestPerch alongside your existing reporters”In playwright.config.ts, import testPerchReporter and add it to your reporter list. This example keeps Playwright’s list reporter and enables TestPerch whenever the shell supplies a key.
import { defineConfig } from "@playwright/test";import { testPerchReporter } from "@testperch/playwright";
export default defineConfig({ reporter: [ ["list"], ...(process.env.TESTPERCH_API_KEY ? [testPerchReporter({ url: "https://testperch.com" })] : []), ],});4. Find your result
Section titled “4. Find your result”Choose a spec you know and substitute its path in this command.
pnpm exec playwright test tests/example.spec.tsOpen Runs in the same TestPerch project. Select the run you just started and find the test title and outcome you saw in your terminal. A failed assertion is also a recorded result. If the run is missing, check that the key was exported in the shell that launched Playwright and that it belongs to this project.
Next, find out why a test failed or send results from GitHub Actions using the same reporter configuration.