-
Follow the steps in the main README to setup the reporter.
-
Change
cypress.config.js
to only usebeforeRunHook
, otherwise the reporter will try to create multiple HTML reporters without all the tests.const { defineConfig } = require('cypress'); const { beforeRunHook } = require('cypress-mochawesome-reporter/lib'); module.exports = defineConfig({ video: true, retries: 0, e2e: { setupNodeEvents(on, config) { on('before:run', async (details) => { await beforeRunHook(details); }); }, }, });
-
run tests:
-
Because cypress parallel runs in threads you will need to manually clear the report output folder before run.
-
Set
cypress-parallel
reporter tocypress-mochawesome-reporter
and setcypressParallel=true
reporter option to make the reporter aware ofcypress-parallel
.cypress-parallel -s cy:run -t 2 -d 'cypress/e2e/**/*.cy.js' -r 'cypress-mochawesome-reporter' -o 'cypressParallel=true'"
-
Create report after test run:
npx generate-mochawesome-report --set-exit-code
--set-exit-code
will set the exit code to the number of failed tests, as Cypress does. If you dont want this behavior, you can remove the flag or set--set-exit-code false
.
Example scripts section in
package.json
:"scripts": { "cy:run": "cypress run", "cy:run:parallel": "cypress-parallel -s cy:run -t 2 -d 'cypress/e2e/**/*.cy.js' -r 'cypress-mochawesome-reporter' -o 'cypressParallel=true'", "clean": "rimraf cypress/reports", "generate-report": "generate-mochawesome-report --set-exit-code", "test": "npm run clean && npm run cy:run:parallel || true && npm run generate-report" },
-
cypress-parallel
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||