Course contentsShow
← React
Lesson 2206 of 2,39648. End-to-End TestingFree lesson

Preview Deployment E2E Testing

Run E2E tests against preview deployments (Vercel, Netlify) to catch integration issues before production.

Preview Deployment E2E Testing

What you'll learn: How to run E2E tests against preview deployments to catch integration bugs before they reach production.

The Problem with Testing Only Locally

You've been running E2E tests in CI against your local build, which is great for catching regressions. But there's a gap: the environment where tests run might differ from where your app actually deploys. Environment variables, CDN behavior, serverless functions, and even build configurations can vary between local and production environments.

Preview deployments (like Vercel's preview URLs or Netlify's deploy previews) are production-like environments created automatically for each pull request. They're perfect for E2E testing because they mirror real deployment conditions.

How It Works

When you push code to a PR, your deployment platform generates a unique URL. Instead of testing against localhost:3000, you configure your E2E tests to run against this preview URL. This catches issues like:

  • Environment variable misconfigurations
  • API endpoints pointing to wrong environments
  • CDN caching problems
  • Serverless function cold start issues
  • Cross-origin resource sharing (CORS) errors

Setting It Up

In your CI workflow (like GitHub Actions), wait for the preview deployment, then run Playwright tests against it:

# .github/workflows/e2e.yml
- name: Wait for Vercel Preview
  uses: patrickedqvist/wait-for-vercel-preview@v1.2.0
  
- name: Run E2E Tests
  run: npx playwright test
  env:
    BASE_URL: ${{ steps.wait-for-vercel.outputs.url }}

Your Playwright config reads BASE_URL from the environment, pointing tests at the live preview instead of localhost.

Key Takeaway: Preview deployment E2E testing catches environment-specific integration issues that local tests miss, giving you confidence before merging to production.