Cypress – Mochawesome Reporting

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.

  1. 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"
No alt text provided for this image

4. Once executed, a folder named – mochawesome-report will be auto-generated with the reports in the mochawesome.html file.

No alt text provided for this image

That’s it. We have now generated the Mochawesome Report successfully.

The source code for this project is available on GitHub.

References:

1.https://www.npmjs.com/package/mochawesome

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Website Powered by WordPress.com.

Up ↑

%d bloggers like this: