This is the detailed guide to generate test results of automation testing using cypress. Before introduction of cypress cloud, one of the tedious tasks for automation testing was to generate reports of testing. This problem was overcome by using cypress cloud, where a team can simultaneously view reports and results of system being tested. But it is not free. If you want an alternative, a small report of tests can be generated by using mochawesome.
It is a package for cypress to generate test report. Follow these steps:
Install necessary packages.
npm i mochawesome mochawesome-merge mochawesome-report-generator
In cypress config, import merge and generator.
const { merge } = require("mochawesome-merge"); const generator = require("mochawesome-report-generator");
In config export add these options
reporter: "mochawesome", reporterOptions: { overwrite: false, html: true, json: true, reportDir: "cypress/reports/mochawesome", },
Now run all tests and see if report is generated. It will be stored in above mentioned folder.
npx cypress run
Report can be accessed in html or json format. Open reports folder and open the main html file in a browser.