# Cypress Documentation
# Source: https://raw.githubusercontent.com/cypress-io/cypress-documentation/main/docs/app/continuous-integration/circleci.mdx
# Path: docs/app/continuous-integration/circleci.mdx

---
title: 'Run Cypress tests in CircleCI: A Step-by-Step Guide'
description: 'Set up CircleCI to run Cypress tests with the Cypress Orb, cache dependencies and build artifacts, and parallelize Cypress tests.'
sidebar_label: CircleCI
---

<ProductHeading product="app" />

# Run Cypress in CircleCI

:::info

##### <Icon name="question-circle" color="#4BBFD2" /> 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](https://circleci.com/developer/orbs/orb/cypress-io/cypress)
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](https://github.com/cypress-io/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](https://circleci.com/developer/orbs/orb/cypress-io/cypress).

A typical project can have:

```yaml title=".circleci/config.yml"
version: 2.1
orbs:
  # "cypress-io/cypress@6" installs the latest published
  # version "s.x.y" of the orb. We recommend you then use
  # the strict explicit version "cypress-io/cypress@6.x.y"
  # to lock the version and prevent unexpected CI changes
  cypress: cypress-io/cypress@6
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](/cloud/features/smart-orchestration/parallelization) may have:

```yaml title=".circleci/config.yml"
version: 2.1
orbs:
  cypress: cypress-io/cypress@6
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](https://github.com/cypress-io/circleci-orb/blob/master/src/examples).

:::info

The Cypress <Icon name="github" inline="true" contentType="rwa" /> uses the
Circle CI [Cypress Orb](https://github.com/cypress-io/circleci-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](https://cloud.cypress.io/projects/7s5okt).

{/* prettier-ignore */}
Check out the full <Icon name="github" inline="true" callout="RWA Circle CI configuration" url="https://github.com/cypress-io/cypress-realworld-app/blob/develop/.circleci/config.yml" />.

:::

## Additional Examples

### Component Testing Example

```yaml title=".circleci/config.yml"
version: 2.1
orbs:
  cypress: cypress-io/cypress@6
workflows:
  test:
    jobs:
      - cypress/run:
          cypress-command: 'npx cypress run --component'
```

### Yarn Example

```yaml title=".circleci/config.yml"
version: 2.1
orbs:
  cypress: cypress-io/cypress@6
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 Chrome, Chrome for Testing, Edge, Firefox and the geckodriver to run your tests.
This is only needed if you are passing the `--browser` flag in your `cypress-command`.

```yaml title=".circleci/config.yml"
version: 2.1
orbs:
  cypress: cypress-io/cypress@6
workflows:
  test:
    jobs:
      - cypress/run:
          install-browsers: true
          start-command: 'npm run start'
          cypress-command: 'npx cypress run --browser chrome'
```