How to Generate Junit Reports in Cypress

Working on report
Reading Time: 2 minutes

Hi Readers,
In this blog, we will learn about how to generate Junit Reports in Cypress.


Cypress is a free, open-source, and end-to-end testing framework for web test automation. It helps developers to write automated web tests in Javascript.

It is a front-end and back-end test automation tool for the next generation of modern web applications. Many big companies like Alibaba Travels, and CircleCI uses cypress.

Reporters in Cypress

Cypress is built on top of Mocha, which means any reporter made for Mocha can be used in Cypress. The primary purpose of all kinds of reporters is to provide the number of passed tests, failed tests, and time duration to execute a test which will be useful for debugging. In Cypress, users can create different reports like Mocha, Junit, and teamcity reports.

The team of has also added the two most common 3rd party reporters for Mocha. These are built into Cypress and you can use them without installing anything.

  • TeamCity
  • Junit

All kind of reporters produces the same report but in different style format like in this Blog, we are generating Junit report so it will produce an XML file, and this file, we can open in different browsers like Chrome, Firefox, etc.

Junit Reports

Mocha Junit Reporter generates Junit XML file for each spec.

Steps to create Junit Reports in Cypress

  • Write your test scripts inside the integration folder such that –
  • After the test scripts, install the package for the JUnit report. For installation, run the command −
   npm install cypress-junit-reporter --save-dev
  • After the installation of the packages, Add this code to your cypress.json.
   "reporter": "junit",

   "reporterOptions": {

      "mochaFile": "cypress/results/results.xml",

      "toConsole": true

With the help of this above code, it will create Junit report But the problem is that it will overwrite the reports if we have multiple tests in a run. To solve this problem and wish to have a unique report for individual spec files, we have to add [hash] in the mochaFile parameter in cypress.json.

   "reporter": "junit",

   "reporterOptions": {

      "mochaFile": "cypress/results/results-[hash].xml",

      "toConsole": true


To generate a report for all specs in the integration folder of the Cypress project, run the command −

   npx cypress run --reporter junit

After running this command, the User can see the results folder inside the integration folder where the user can see the reports.


Written by 

Himanshu is an intern at Knoldus Inc. practicing in Test Automation Studio. He is familiar with the concepts of manual testing and automated testing using Cypress and Postman. He is always eager to learn new and advanced concepts in order to upskill himself. He likes to watch marvel movies and loves to play Badminton.