Peeps code review needs none of this. It reviews every pull request on a repository where code review is on, whether or not you deploy previews.
1. Let Vercel tell GitHub about deployments
In Vercel, open your project, then Settings > Git, and turn on deployment_status Events. New Vercel projects leave this off. Without it, Vercel posts only a commit status that links to the Vercel dashboard, and nothing in GitHub says where the preview lives. With it on, Vercel records a GitHub deployment for each commit, with the preview’s URL.2. Test the pull request’s preview
Addpreview: vercel to the Peeps step and run the workflow on pull_request. On a pull request the Peeps action waits for the preview of the pull request’s head commit and sets BASE_URL to it before your tests start.
Start the job from pull_request, not from Vercel’s deployment_status event: Peeps counts a job as the pull request’s tests only when it runs on the pull request. See Pull request tests below.
.github/workflows/peeps.yml
preview: vercel does:
- It finds the GitHub deployment Vercel recorded for the pull request’s head commit, in the
Previewenvironment, and waits until it succeeds: up to 10 minutes, orpreview-timeoutseconds. - When the repository deploys several Vercel projects, name the one to test with
preview-project, for examplepreview-project: web. - When Vercel deployed the commit but recorded no GitHub deployment, it stops at once and tells you to turn on deployment_status Events (step 1).
- A
BASE_URLyour workflow sets itself wins. - When Peeps starts the workflow to fix a failed test, the fix runs on the preview of the commit it checked out, so a pull request’s failure is fixed against that pull request’s own preview.
PRODUCTION_URL above, an Actions variable). A production deployment’s own URL is behind Deployment Protection too; the domain is not.
Point your Playwright config at BASE_URL:
playwright.config.ts
3. Get through Deployment Protection
Vercel’s Standard Protection sends every visitor of a preview to Log in to Vercel. Your tests are visitors too. When they hit it, every test fails on the login page, and Peeps’ failure analysis says the preview’s Deployment Protection stopped the test. Let your CI through with a Trusted Source. Nothing is stored: each job proves which repository it runs in with its own short-lived GitHub token.1
Add the trusted source
In Vercel, open your project, then Settings > Deployment Protection > Trusted Sources > Add trusted source > External Service. Choose GitHub Actions, your GitHub account, and the repository whose workflow runs the tests. Keep the default audience,
https://github.com/<your account>, and the Preview environment. Click Add.2
Send the token from your tests
A job with Import
id-token: write can request its own GitHub token at any time. Each one lasts five minutes, and Vercel sets no cookie for it, so request it in the test process, send it as the x-vercel-trusted-oidc-idp-token header on every request to the deployment under test, and renew it before it expires:tests/fixtures.ts
test and expect from this file in your specs instead of from @playwright/test. The token goes only to the deployment under test, never to another site the page loads from.VERCEL_AUTOMATION_BYPASS_SECRET, and send it as the x-vercel-protection-bypass header in the same fixture. Unlike the trusted source’s token it does not expire, and Playwright traces record request headers, so set trace: "off" while it is set.
Pull request tests
On the project’s Repository settings page, under Pull request tests:- Choose the Smoke tests: a selection of the tests every pull request runs. Tests the pull request adds run too.
- Under On a pull request, your tests run against, choose That pull request’s own build.
- Vercel tells GitHub where each preview is: ticked when Vercel recorded a GitHub deployment for the pull request’s commit. If Vercel built it without one, the row tells you to turn on deployment_status Events (step 1).
- Pull requests test their own Vercel preview: ticked when the pull request’s tests ran against a Vercel deployment. If not, the row tells you to add
preview: vercel(step 2).
Troubleshooting
Known limits
- The fix assistant in Peeps can’t open a protected preview. It runs in Peeps, not in your CI, so your workflow’s trusted-source token doesn’t reach it, and Peeps sends your project’s HTTP headers only to your environments’ URLs. It can still read the run’s evidence; to look at the preview itself, open it in your browser.
- A fork’s pull request is not tested on its preview.
preview: vercelrefuses pull requests from forks andpull_request_target, because a fork’s preview runs the fork’s code.