Member-only story

Cypress — merging multiple mochawesome reports

Kristijan
3 min readFeb 18, 2020

In my last post I described how to set up mochawesome reports for Cypress tests. However, I also mentioned at the end of it a problem. It generates separate file for every test suit. In this post I will describe how to solve that problem and have just one report containing all test results.

Installation

For this you will need new npm dependencies. That is mochawesome-merge package which you can download by running next CLI command:

npm install mochawesome-merge --save-dev

This command will take multiple JSON outputs and create one containing all. I know you might want HTML report, but first we need to create JSON one to generate HTML from it.

Running tests

Let’s first run tests. Because mochawesome generates separate report for each test suite, we will need to disable overwrite in report options for cypress. Also, we need to enable only JSON format, because we will be running merge on those.

// cypress.json
{
"reporter": "mochawesome",
"reporterOptions": {
"charts": true,
"overwrite": false,
"html": false,
"json": true,
"reportDir": "cypress/report/mochawesome-report"
}
}

We can do all that with configuration above. Also, it will save reports in…

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (2)

What are your thoughts?

Thanks for the tutorial, very useful - especially the detail about having to delete old files.

Hi Kristijan, just ran through this and worked great. With one exception:
mochawesome-merge cypress/report/mochawesome-report/*.json > cypress/report/output.json
Needed to be changed to:
mochawesome-merge…