Web Automation Testing with Cypress : A Guide for Beginners (II)

Sony
by Sony 

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:

  1. Install Mocha

npm install mocha –save-dev

  1. Install cypress multi-reporters

npm install cypress-multi-reports – save-dev

  1. Install Mochawesome:

npm install mochawesome –save-dev

  1. Install mochawesome merge

npm install mochawesome-merge –save-dev

  1. 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”,

UI of cypress web automation tool

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.

Ui of cypress web automation tool

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.

Conclusion

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 abut building software that solve real world problems. Need a team of expert testers who can bring your product to the next level? Or need help with automating your software tests? We can help you. Book a free consulting call with us today!

Further Reading

Selenium VS Cypress - The Test Tribe

Cypress Tutorial - Tutorials Point

Design QA as a system - Gurzu Inc