https://glebbahmutov.com/blog/cypress-lighthouse/
: Cypress Lighthouse integration link
Zero config Mochawesome reporter for Cypress with screenshots attached to tests.
reporter version | cypress version | reporter branch |
---|---|---|
v3 |
node >= 14 >= 6.7.0 >= 6.2.0 with experimentalRunEvents: true |
master |
v2 |
>= 6.7.0 >= 6.2.0 with experimentalRunEvents: true |
v2 |
v1 |
>= 4.0.0 |
v1 |
- install cypress-mochawesome-reporter
npm i --save-dev cypress-mochawesome-reporter
or
yarn add -D cypress-mochawesome-reporter
- Change cypress reporter
config file (cypress.json
by default)
"reporter": "cypress-mochawesome-reporter"
or command line
--reporter cypress-mochawesome-reporter
- Add to
cypress/support/index.js
import "cypress-mochawesome-reporter/register";
- Add to
cypress/plugins/index.js
module.exports = (on, config) => {
require("cypress-mochawesome-reporter/plugin")(on);
};
or (cypress-mochawesome-reporter
>= 2.2.0
)
const {
beforeRunHook,
afterRunHook,
} = require("cypress-mochawesome-reporter/lib");
module.exports = (on) => {
on("before:run", async (details) => {
console.log("override before:run");
await beforeRunHook(details);
});
on("after:run", async () => {
console.log("override after:run");
await afterRunHook();
});
};
- run cypress
If you want to customize your HTML report with mochawesome-report-generator flags just add the flags you want to reporterOptions
{
"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
"reportDir": "cypress/report",
"charts": true,
"reportPageTitle": "custom-title"
}
}
Additional reporter options:
name | type | default | description |
---|---|---|---|
embeddedScreenshots |
boolean |
false |
Embedded external screenshots into HTML using base64, use with inlineAssets option to produce a single HTML file |
quiet |
boolean |
false |
Silence console messages |
saveAllAttempts |
boolean |
true |
Save screenshots of all test attempts, set to false to save only the last attempt |
debug |
boolean |
false |
Creates log file with debug data |
- Simple use of
cypress-mochawesome-reporter
- Using
cypress-multi-reporters
- With
mochawesome-report-generator
flags - Change default screenshots folder in
cypress.json
Run npm i
in root directory then:
cd examples/<example-project>
npm i
npm test