Skip to content

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.

Run this command in the package that contains your Playwright configuration.

Terminal window
pnpm add -D @testperch/playwright

Keep the existing @playwright/test installation. If your project uses npm, use npm install --save-dev @testperch/playwright.

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.

Terminal window
read -rs -p 'Reporter key: ' TESTPERCH_API_KEY
echo
export TESTPERCH_API_KEY

3. 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" })] : []),
],
});

Choose a spec you know and substitute its path in this command.

Terminal window
pnpm exec playwright test tests/example.spec.ts

Open 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.