Generate Cypress MochAwesome Reporter

MochAwesome Reporter
   

Cypress compatibility:

node >= 14
Cypress >= 6.7.0

Setup:

  1. install cypress-mochawesome-reporter:
npm i --save-dev cypress-mochawesome-reporter

or

yarn add -D cypress-mochawesome-reporter
  1. Change cypress reporter:

const { defineConfig } = require('cypress');

module.exports = defineConfig({
  reporter: 'cypress-mochawesome-reporter',
  e2e: {
    setupNodeEvents(on, config) {
      require('cypress-mochawesome-reporter/plugin')(on);
    },
  },
});

or command line

--reporter cypress-mochawesome-reporter
  1. Add to cypress/support/e2e.js:
import 'cypress-mochawesome-reporter/register';
  1. Custom Options: If you want to customize your HTML report with mochawesome-report-generator flags just add the flags you want to reporterOptions
const { defineConfig } = require('cypress');

module.exports = defineConfig({
  reporter: 'cypress-mochawesome-reporter',
  reporterOptions: {
    charts: true,
    reportPageTitle: 'custom-title',
    embeddedScreenshots: true,
    inlineAssets: true,
    saveAllAttempts: false,
  },
  e2e: {
    setupNodeEvents(on, config) {
      require('cypress-mochawesome-reporter/plugin')(on);
    },
  },
});

5. Run test cases or project: 

npx cypress run --browser chrome


Source: https://github.com/LironEr/cypress-mochawesome-reporter

Share the Knowledge

You May Also Like

About the Author: codenbox

Leave a Reply

Your email address will not be published. Required fields are marked *