How can I run end-to-end tests after my Vercel Preview Deployment?

Learn how to use the Vercel CLI in combination with your CI/CD provider to run end-to-end tests for every code change.
Last updated on March 16, 2023
Build, Deployment & Git

You can use Vercel's webhooks with your Git provider to run an end-to-end test suite after your Vercel deployment has finished. This example will use GitHub Actions, but you can use any of our supported Git providers.

  1. Connect your Git repository to your project. For new projects, you can follow these docs. For existing projects, visit your Git configuration in the Settings tab of your project dashboard.
  2. Create a GitHub workflow in .github/workflows with the following:
name: Playwright Tests
on:
deployment_status:
jobs:
run-e2es:
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm ci && npx playwright install --with-deps
- name: Run tests
run: npx playwright test
env:
BASE_URL: ${{ github.event.deployment_status.environment_url }}
A GitHub Action that runs an end-to-end test suite using Playwright, testing the Vercel Preview Deployment.

Couldn't find the guide you need?