Integrate Cypress into your CI provider
- out of the box (integration without extra jobs)
- automated (start server and test, abort CI build when a test fails)
- safe (no more
Ctrl-C
, server will be shutdown gracefully) - extendable (import local Cypress configuration file)
- reports (export test result as a file while logging console outputs)
Add the script below in build script in your CI provider before a build.
cypress-ci -s <serve> -u <url>
Jenkins freestyle with npm scripts
#!/bin/bash
cd /var/lib/jenkins/workspace/your-project-directory
npm ci
npm run cypress:ci
npm run build
npm install --save-dev cypress-ci
yarn add --dev cypress-ci
You need dependencies below before running Cypress in CI providers.
Read official Cypress documents
- https://docs.cypress.io/examples/examples/docker#Images
- https://www.cypress.io/blog/2019/05/02/run-cypress-with-a-single-docker-command/
Ubuntu/Debian
apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
CentOS
yum install -y xorg-x11-server-Xvfb gtk2-devel gtk3-devel libnotify-deve
"scripts": {
"start": "webpack serve --config webpack.config.js",
"cypress:ci": "cypress-ci -s start -u http://localhost:3000 -c cypress.ci.json"
}
option | description | default |
---|---|---|
-s , --serve |
script to run server | start |
-u , --url |
url to test | http://localhost:3000 |
-t , --timeout |
maximum time in ms to wait for a server response | 60000 |
-V , --version |
output the version number | |
-h , --help |
display help for command |
- Import and override Cypress config file
- Support typescript
- Run on a docker image
- Provide webpack plugin
MIT