How to Run Cypress End-to-End Tests with GitHub Actions
The official cypress-io/github-action installs Cypress, caches the binary, starts your app, waits for it, and runs the specs.
Use cypress-io/github-action, passing start to launch your dev server and wait-on to block until it answers. Upload screenshots on failure so flaky UI tests are debuggable.
Steps
- Use
cypress-io/github-action, which installs and caches the binary. - Set
startto your app command andwait-onto the URL it serves. - Upload
cypress/screenshots/withif: failure().
Workflow
.github/workflows/ci.yml
jobs:
e2e:
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'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots/Gotchas
- Without
wait-on, Cypress may hit the server before it is listening and fail with a connection refused error. - The action installs dependencies for you, so a separate
npm cistep is usually redundant.
Related guides
How to Run Playwright End-to-End Tests with GitHub ActionsRun Playwright end-to-end tests in GitHub Actions, installing browsers with their system dependencies and upl…
How to Run Browser Tests in Headless Chrome with GitHub ActionsRun browser-based unit tests in GitHub Actions using headless Chrome with Karma or a similar runner, since th…