Reporters

Improve this doc

Because Cypress is built on top of Mocha, that means any reporter built for Mocha can be used with Cypress. Here is a list of built in Mocha reporters.

We’ve also added the two most common 3rd party reporters for Mocha. These are built into Cypress and you can use them without installing anything.

Finally we support creating your own custom reporters or using any kind of 3rd party reporter.

Did you know that you can use multiple reporters with Mocha?

This is especially useful when running in CI. Typically we see users using the default spec reporter to show up in stdout but then also generate an actual report file for junit.

Custom Reporters

Cypress supports custom reporters, whether local to your project or installed through .

Local Reporters

Say you have the following directory structure:

> my-project
  > cypress
  > src
  > reporters
    - custom.js

To specify the path to your custom reporter:

// cypress.json

{
  "reporter": "reporters/custom.js"
}

The path above is relative to where your cypress.json is located.

Command line

cypress run --reporter reporters/custom.js

We also support passing an absolute path to the reporter.

npm Reporters

If you installed a custom reporter through npm, specify the package name:

// cypress.json

{
  "reporter": "mochawesome"
}

Command line

cypress run --reporter mochawesome

You need to install any peer dependencies the reporter requires, even if they’re bundled with Cypress. For example, mochawesome requires mocha as a peer dependency. You will need to install mocha as a dev dependency of your own project for it to work.

Reporter Options

Some reporters accept options that customize their behavior. These can be specified in your cypress.json or via the command line:

cypress.json

{
  "reporter": "junit",
  "reporterOptions": {
    "mochaFile": "results/my-test-output.xml",
    "toConsole": true
  }
}

Command line

cypress run --reporter junit --reporter-options "mochaFile=results/my-test-output.xml,toConsole=true"

Reporter options differ depending on the reporter (and may not be supported at all). Refer to the documentation for the reporter you are using for details on which options are supported.

Multiple Reporters

Oftentimes we see users wanting the ability to use multiple reporters. When running in CI, you might want to generate a report for junit or perhaps a json report. This is great, but by setting this reporter you won’t receive any additional feedback while the tests are running!

The solution here is to use multiple reporters! You can have the benefit of both worlds.

We suggest using the excellent npm module:

https://github.com/stanleyhlng/mocha-multi-reporters

We use multiple reporters for every single one of our internal projects.

Here is an example for reference:

https://github.com/cypress-io/cypress-example-docker-circle#generate-just-xml-report