Cypress is becoming very famous among the test automation tools. It offers online live dashboard of the paid version. Perhaps there are requirements to get offline reporting from Cypress.
In this article, we will see how to generate offline Cypress report. To generate one, we will be using a node package – Mochawesome.
It is a custom made reporting framework by Adam Gruber. In general, this is used to generate test reports for Mocha based test frameworks. Since Mocha is an in-built feature of Cypress, we can directly use it.
- Run this command to pull the npm package –
npm install mochawesome --save-dev
2. Add this entry to cypress.json
{ "reporter":"mochawesome" }
Tips:
a. Make sure you have mocha 5.2.0 version, else install it by
npm install mocha@5.2.0 --save-dev
b. Please note that Mochawesome will not be able to generate the reports when we run the tests from Test Runner. It has to be executed from the command prompt/terminal.
3. Let’s now run the tests by executing the below command
./node_modules/.bin/cypress run --spec "cypress/integration/examples/actions.spec.js"
4. Once executed, a folder named – mochawesome-report will be auto-generated with the reports in the mochawesome.html file.
That’s it. We have now generated the Mochawesome Report successfully.
The source code for this project is available on GitHub.
References:
Leave a Reply