Member-only story
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 a separate file for every test suit. In this post, I describe how to solve that problem and have just one report containing all test results.
Installation
For this, you need new npm dependencies. That is mochawesome-merge package, which you can download by running the next CLI command:
npm install mochawesome-merge — save-dev
This command takes multiple JSON outputs and creates one containing all. I know you might want an HTML report, but first, we need to create JSON to generate HTML from it.
Running tests
Let’s first run tests. Because mochawesome generates a separate report for each test suite, we need to disable overwrite in report options for cypress. Also, we need to enable only JSON format because we need to merge 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 the configuration above. Also, it saves reports in…