Skip to content

joergmis/vercel-cypress

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vercel-cypress

GitHub action which allows you to run Cypress tests against a Vercel preview deployment.

Prerequisites

Make sure that the API token has the right access scope and that your team id is correct. You can do this with the following check; the output should be a large json payload.

# reference: https://vercel.com/docs/rest-api/endpoints#list-deployments
export TOKEN=YOUR_VERCEL_API_TOKEN

export PROJECT_ID=YOUR_PROJECT_ID
curl -X GET "https://api.vercel.com/v6/deployments?projectId=${PROJECT_ID}" \
  -H "Authorization: Bearer ${TOKEN}"

# for team projects
export TEAM_ID=YOUR_TEAM_ID
curl -X GET "https://api.vercel.com/v6/deployments?projectId=${PROJECT_ID}&teamId=${TEAM_ID}" \
  -H "Authorization: Bearer ${TOKEN}"

Usage

The following action will wait for the Vercel deployment to finish, then run Cypress but override the URL provided to Cypress' config to the latest Vercel deployment URL.

name: my-action

# (only) run after a successful deployment
on: deployment

jobs:
  regression:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: actions/vercel-cypress@v1
        with:
          # required: vercel API token
          vercel-token: ${{ secrets.VERCEL_TOKEN }}
          # required: project id
          project-id: your-project-id
          # required if the project is from a team
          team-id: your-team-id
          # optional: parameters that are passed to 'npx cypress run <options>'
          options: "--browser chrome --spec cypress/e2e/base/*"

About

A GitHub action to run Cypress against a Vercel deployment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 50.9%
  • Dockerfile 49.1%