Cypress · Browser testing end to end
How do you run Cypress in CI?
Short answer
Start the app, wait for it to be reachable, and run cypress run with the right browser and config. Cache dependencies, upload screenshots and videos, and use a record key if parallelizing.
A CI run needs the same things as a local headless run, plus orchestration: install dependencies, start the application, wait until it is ready, run Cypress, and preserve artifacts. The most common failure is starting Cypress before the app is reachable.
name: cypress
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cypress-io/github-action@v6
with:
build: npm run build
start: npm start
wait-on: "http://localhost:3000"
browser: chrome
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-artifacts
path: |
cypress/screenshots
cypress/videosCI checklist
- Use a reproducible install such as npm ci
- Set baseUrl to the CI server address
- Wait on a health endpoint before running specs
- Pin the browser and Cypress version
- Upload artifacts on failure, not only on success
- Keep secrets such as a record key in CI secrets
- Run the same command locally so CI is not a separate universe
Cache the package manager and the Cypress binary to save time, but invalidate the cache when the Cypress version changes. If tests need a database, provision it in the job and seed it deterministically before the run.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1Why does CI need a wait-on step?
- 2How do you preserve screenshots from a failed job?
- 3What should be cached in a Cypress CI job?
- 4How do you keep secrets out of the repository?
Say it in the interview
A CI job installs dependencies, builds and starts the app, waits until it responds, and then runs cypress run with a pinned browser. I upload screenshots and videos only when the job fails, and I keep any record key in CI secrets. I also make sure the same command works locally. Most CI failures I have seen come from starting Cypress before the app is ready or from a missing environment variable.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Cypress mock interview and get scored feedback on depth, clarity and confidence.