How to Run Cypress End-to-End Tests in CircleCI
The cypress-io/cypress orb handles install, caching, and running the suite, including starting your app and waiting on it before tests begin.
Import cypress-io/cypress and call its run job (or install + run steps). Use start-command and wait-on so the dev server is up before Cypress runs.
Steps
- Add the
cypressorb underorbs:. - Use
cypress/runwithstart-commandto boot your app andwait-onto block until it answers. - Add
parallelismand--recordto split a large spec set across containers.
Config
.circleci/config.yml
version: 2.1
orbs:
cypress: cypress-io/cypress@3.3.0
workflows:
e2e:
jobs:
- cypress/run:
start-command: "npm start"
wait-on: "http://localhost:3000"
cypress-command: "npx cypress run"Gotchas
- Without
wait-on, Cypress can start before the server is ready and fail with connection refused. - Recording and load balancing across parallel containers needs a Cypress Cloud record key set as an env var.
Related guides
How to Install Node Dependencies With the Node Orb in CircleCIInstall and cache Node dependencies in CircleCI with the official node orb, which detects your package manage…
How to Use pre-steps and post-steps in CircleCIInject setup and teardown around a reusable CircleCI job using pre-steps and post-steps when invoking it in a…