Skip to main content

CircleCI

info
What you'll learn​
  • How to set up CircleCI to run Cypress tests with the Cypress Orb
  • How to cache dependencies and build artifacts
  • How to parallelize Cypress tests with CircleCI

The Cypress CircleCI Orb is the official CircleCI Orb of Cypress. Although you don't need to use the orb to run your tests in CircleCI, the benefit of using the orb is that it allows you to easily install, cache and run Cypress tests in CircleCI with less effort. The orb abstracts common steps necessary for running your tests in CircleCI in order to make your life as a developer better!

Basic Setup​

The Cypress CircleCI Orb is a piece of configuration set in your .circleci/config.yml file to correctly install, cache and run Cypress with very little effort.

For the Orb Quick Start Guide and usage cases, view the CircleCI Cypress orb documentation.

A typical project can have:

.circleci/config.yml
version: 2.1
orbs:
# "cypress-io/cypress@3" installs the latest published
# version "s.x.y" of the orb. We recommend you then use
# the strict explicit version "cypress-io/[email protected]"
# to lock the version and prevent unexpected CI changes
cypress: cypress-io/cypress@3
workflows:
build:
jobs:
- cypress/run # "run" job comes from "cypress" orb
start-command: 'npm run start'

That's it! Your repo's dependencies will be installed and cached and your Cypress tests will run in CircleCI

Parallelization​

A more complex project that needs to install dependencies, start a server, and run tests across 4 CI machines in parallel may have:

.circleci/config.yml
version: 2.1
orbs:
cypress: cypress-io/cypress@3
workflows:
build:
jobs:
- cypress/run:
start-command: 'npm run start'
cypress-command: 'npx cypress run --parallel --record --group all tests'
parallelism: 4

Using the orb brings simplicity and static checks of parameters to CircleCI configuration.

You can find additional examples at our orb examples page.

info

The Cypress Real World App (RWA) uses the Circle CI Cypress Orb, Codecov Orb, and Windows Orb to test over 300 test cases in parallel across 25 machines, multiple browsers, multiple device sizes, and multiple operating systems with full code-coverage reporting and Cypress Cloud recording.

Check out the full RWA Circle CI configuration.

Additional Examples​

Component Testing Example​

.circleci/config.yml
version: 2.1
orbs:
cypress: cypress-io/cypress@3
workflows:
test:
jobs:
- cypress/run:
cypress-command: 'npx cypress run --component'

Yarn Example​

.circleci/config.yml
version: 2.1
orbs:
cypress: cypress-io/cypress@3
workflows:
test:
jobs:
- cypress/run:
package-manager: 'yarn'
start-command: 'yarn start'

Chrome Example​

Cypress uses Electron by default to run your tests. The install-browsers flag is used to install Firefox and Chrome to run your tests. This is only needed if you are passing the --browser flag in your cypress-command

.circleci/config.yml
version: 2.1
orbs:
cypress: cypress-io/cypress@3
workflows:
test:
jobs:
- cypress/run:
install-browsers: true
start-command: 'npm run start'
cypress-command: 'npx cypress run --browser chrome'