Cypress compatibility:
node >= 14
Cypress >= 6.7.0
Setup:
- install cypress-mochawesome-reporter:
npm i --save-dev cypress-mochawesome-reporter
or
yarn add -D cypress-mochawesome-reporter
- 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
Add to:cypress/support/e2e.js
import 'cypress-mochawesome-reporter/register';
- 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