In the first part of this blog (Read here) we went through the basics of cypress and how to run web automation testing in it. In the part II - we will learn another important feature - generating a report.
How to generate a report in Cypress
We can build a report in cypress using the Mocha report. To generate the report, we need to install proper reporters. We can generate the report in different forms like HTML, Console, and XML. For this, we use the cypress-multi-reporters package.
Follow the following steps:
- Install Mocha
npm install mocha –save-dev
- Install cypress multi-reporters
npm install cypress-multi-reports – save-dev
- Install Mochawesome:
npm install mochawesome –save-dev
- Install mochawesome merge
npm install mochawesome-merge –save-dev
- Install mochawesome-report-generator
npm install mochawesome-report-generator –save-dev
After these steps: Add scripts in package.json
”combine-reports”: “mochawesome-merge cypress/reports/mocha/*.json > cypress/reports/mochareports/report.json”,
”generate-report”: “marge cypress/reports/mochareports/report.json -f report -o cypress/reports/mochareports”,
In the package.json file, users can add cy=cypress open they can define here and can use shortcuts during running the cypress.
Once the script has run, the HTML report will appear in the cypress/results/html folder.
Challenges of frequently changing requirements
We mostly did automation testing for repeated stuff that we are doing in testing (mostly regression). We can do automation for the project where the required changes are small. If the requirement changes frequently, we have to redo the entire scope of testing since even the smallest changes to a codebase need to be run through multiple tests to ensure its stability and compatibility with existing code, which will be time-consuming and frustrating. It is quite hard to handle if there are tight deadlines to deliver the results.
Cypress is a powerful tool for End-to-End testing, which is easier to set up and learn. It provides us with a visual interface to indicate whether the test commands have been successfully executed, passed, or failed.
We can run automation for repeated stuff (regression testing) and can automate the project where the required changes are small.
Gurzu is a software development company in Nepal - passionate about building software that solve real world problems. Have a tech idea you want to turn into reality? Book a free consulting call!