How to Run Cypress Tests in CI on GitHub Actions
The official cypress-io/github-action wraps install, caching, server startup, and the test run behind a single step.
Use cypress-io/github-action with start to boot your app and wait-on to hold until it responds, so the browser tests run against a live server.
Steps
- Check out the repo and set up Node.
- Use
cypress-io/github-actionwithstart: npm start. - Set
wait-onto your app URL so tests wait for readiness. - Upload screenshots and videos on failure.
Workflow
.github/workflows/ci.yml
jobs:
cypress:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- uses: cypress-io/github-action@v6
with:
start: npm start
wait-on: 'http://localhost:3000'
wait-on-timeout: 120
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-artifacts
path: |
cypress/screenshots
cypress/videosGotchas
- The action caches the Cypress binary automatically; do not also cache
~/.cache/Cypressby hand or you double the work. - On Linux the action runs under xvfb for you, so no manual virtual display setup is needed.
Related guides
How to Run Cypress in Parallel With Cypress Cloud in GitHub ActionsRecord and parallelize Cypress runs across GitHub Actions machines using Cypress Cloud with the record and pa…
How to Run E2E Tests Against a Preview URL in GitHub ActionsPoint Playwright or Cypress at a deployed preview URL in GitHub Actions instead of a local server, passing th…