Next-Gen App & Browser Testing Cloud
Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

The deployment_status trigger, the protection-bypass header, and a real GitHub Actions workflow for E2E testing on every preview.

Mythili Raju
Author

Shahzeb Hoda
Reviewer
Published on: August 27, 2026
Your CI job finds the preview URL, launches Playwright against it, and every test fails on a login screen your app doesn't have. Nothing broke in the deploy. Vercel's own Deployment Protection is doing exactly what it's configured to do: gate the URL from anyone without a session, including your test runner.
That single wrong turn accounts for most "why can't I test my preview deployment" threads. The fix is documented, current, and narrower than most guides make it sound.
This covers how previews actually trigger, the two URL types, getting the URL into CI, the protection bypass for both API and in-browser tests, a working GitHub Actions workflow, and a one-command alternative to maintaining a Playwright spec for every preview.
TL;DR
Testing a Vercel preview deployment automatically means capturing the exact preview URL from the deployment_status GitHub event, then sending the x-vercel-protection-bypass header (or an x-vercel-set-bypass-cookie for a multi-page browser session) so your test traffic clears Deployment Protection the same way a real teammate's session does.
Vercel's environments documentation defines three defaults: Local, Preview, and Production. A Preview deployment is created when you push a commit to a non-production branch, open a pull request, or run the CLI without --prod.
One exception worth knowing before it confuses a first CI run: the very first deployment of a brand-new project is always a production deployment, regardless of which branch or flag you used.
| URL type | Points to | Use for automated tests? |
|---|---|---|
| Branch-specific | Always the latest deployment on that branch | Risky - a new push can swap the app underneath a still-running test |
| Commit-specific | The exact deployment of that one commit, permanently | Preferred - ties the test run to the exact code it validated |
Grab the commit-specific URL from the deployment event rather than constructing the branch URL yourself; the next section covers exactly where that URL lives.
GitHub fires a deployment_status event on your repository as Vercel's integration creates and updates the deployment. Filter it for the moment the deployment finished successfully:
on:
deployment_status:
jobs:
e2e:
if: github.event.deployment_status.state == 'success' &&
github.event.deployment_status.environment == 'Preview'
runs-on: ubuntu-latest
steps:
- name: Capture the preview URL
run: echo "PREVIEW_URL=${{ github.event.deployment_status.target_url }}" >> $GITHUB_ENVThat target_url field is the commit-specific preview URL. Everything downstream, Playwright, Kane CLI, or any other tool, points at $PREVIEW_URL from here.
Note: TestMu AI's Kane CLI takes the captured preview URL and a plain-English objective, no Playwright spec required. Try TestMu AI free!
Vercel's Protection Bypass for Automation documentation exists because Deployment Protection, Vercel Authentication, Password Protection, or Trusted IPs, is on by default for most teams and blocks exactly the traffic a test runner sends.
Vercel automatically sets a secret as the VERCEL_AUTOMATION_BYPASS_SECRET system environment variable once bypass is configured for the project. The documented, recommended method is sending it as a header:
Here's the part most guides skip: a single header only clears the one request it's attached to. A real browser session, the kind an E2E test drives, makes many requests as it navigates. For that, Vercel's docs specify a second header, x-vercel-set-bypass-cookie: true, which sets the bypass as a cookie via a redirect so every subsequent page load in the session stays authorized. Inside an iframe, the value needs to be samesitenone instead.
Vercel's own documentation ships a Playwright example using exactly these two headers together:
// playwright.config.ts
import { defineConfig } from '@playwright/test';
if (!process.env.VERCEL_AUTOMATION_BYPASS_SECRET) {
throw new Error(
'VERCEL_AUTOMATION_BYPASS_SECRET is required to run tests against protected deployments',
);
}
export default defineConfig({
use: {
extraHTTPHeaders: {
'x-vercel-protection-bypass': process.env.VERCEL_AUTOMATION_BYPASS_SECRET,
// Use 'samesitenone' instead of 'true' when testing in an iframe.
'x-vercel-set-bypass-cookie': 'true',
},
},
});Combined with the deployment_status trigger from earlier, the full loop is: capture $PREVIEW_URL, run Playwright with these headers against it, and the run neither times out on a login screen nor accidentally tests the wrong commit.
Writing and maintaining a Playwright spec is the right call for a stable, well-defined flow. For a fast smoke check on every single preview, Kane CLI from TestMu AI skips the spec file: a plain-English objective, run headless with the same bypass header, against the same captured URL.
npm install -g @testmuai/kane-cli
kane-cli login --username "$LT_USERNAME" --access-key "$LT_ACCESS_KEY"
kane-cli run --agent --headless \
--url "$PREVIEW_URL" \
--header "x-vercel-protection-bypass: $VERCEL_AUTOMATION_BYPASS_SECRET" \
"sign in with the test account, open the dashboard, assert the page
shows the account name"Agent mode's standard exit codes (0 passed, 1 failed, 2 environment error, 3 timeout) drop straight into the same GitHub Actions job as a required check, no separate reporting step. Our dedicated guide to connecting Kane CLI to GitHub Actions covers the full workflow setup, and the Kane CLI introduction documentation covers authentication and the full command reference.
Beyond the default Preview environment, Vercel's Pro plan allows one custom environment per project, and Enterprise allows twelve, per the current documentation. A custom environment like staging can track a specific branch automatically and hold a persistent domain, unlike the constantly-changing default Preview URLs.
A longer-running QA environment is the right target for a fuller regression pass; the per-commit preview URL from earlier is the right target for a fast smoke check on every single change.
Four steps from zero to a preview check that actually runs.
Once the loop runs reliably on every preview, our guide to agent-native CI covers the next step: having an agent triage what actually failed, not just report that it did. If the same check is gating an AI-generated pull request specifically, our breakdown of quality gates for AI pull requests covers where this fits in that broader review process.
Author
Mythili is a Community Contributor at TestMu AI with 3+ years of experience in software testing and marketing. She holds certifications in Automation Testing, KaneAI, Selenium, Appium, Playwright, and Cypress. At TestMu AI, she leads go-to-market (GTM) strategies, collaborates on feature launches, and creates SEO optimized content that bridges technical depth with business relevance. A graduate of St. Joseph’s University, Bangalore, Mythili has authored 35+ blogs and learning hubs on AI-driven test automation and quality engineering. Her work focuses on making complex QA topics accessible while aligning content strategy with product and business goals.
Reviewer
Shahzeb Hoda is the Associate Director of Marketing and a Community Contributor at TestMu AI, leading strategic initiatives in developer marketing, content, and community growth. With 10+ years of experience in quality engineering, software testing, automation testing, and e-learning, he has authored and reviewed 70+ technical articles on software testing and automation. Shahzeb holds an M.Tech in Computer Science from BIT, Mesra, and is certified in Selenium, Cypress, Playwright, Appium, and KaneAI. He brings deep expertise in CI/CD pipeline automation, cross-browser testing, AI-driven testing practices, and framework documentation. On LinkedIn, he is followed by 3,700+ engineers, developers, DevOps professionals, tech leaders, and enthusiasts.
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance