cypressmochawesome

Cypress Mochawesome report create multiple reports per thread


It is observed that when we execute cypress automation tests using Cypress Parallel command with multiple threads, multiple Cypress Mochawesome reports are getting created based on the number of threads used.

Is there any provision to combine these individual reports and generate a single Cypress Mochawesome report?

Contents of the reporter-config.json file is shown below:

  {
    "reporterEnabled": "mocha-junit-reporter, mochawesome, cypress-mochawesome-reporter",
    "mochaJunitReporterReporterOptions": {
      "mochaFile": "cypress/reports/junit_cypress-[hash].xml",
      "toConsole": false
    },
    "cypressMochawesomeReporterReporterOptions": {
      "reportDir": "cypress/reports/mochaReport",
      "reportFilename": "AutoTest",
      "reportPageTitle": “Regression”,
      "reportTitle": "AutoTests",
      "embeddedScreenshots": true,
      "overwrite": false,
      "showPending": false,
      "showSkipped": true,
      "inlineAssets": true,
      "charts": true
    }
  }

Command used to trigger the Cypress Parallel execution:

    "cy:run:parallel": "cypress-parallel -s cy:run -t 3 -d 'cypress/e2e/ui/' -r 'cypress-mochawesome-reporter' -o 'cy`pressParallel=true' -p 'reporter-config.json' --strictMode false "

Solution

  • npm install --save-dev mochawesome mochawesome-merge mochawesome-report-generator

    you should update cypress-parallel scripts

    "cy:run:parallel": "cypress-parallel -s cy:run -t 3 -d 'cypress/e2e/ui/' -r 'cypress-mochawesome-reporter' -o 'cypressParallel=true' -p 'reporter-config.json' --strictMode false && npm run merge-reports"

    add merge-reports scripts

    "merge-reports": "mochawesome-merge cypress/reports/*.json > cypress/reports/merged-report.json && marge cypress/reports/merged-report.json -f merged-report -o cypress/reports"

    example reporter-config.json

    { "reportDir": "cypress/reports", "overwrite": false, "html": false, "json": true }

    you will take a one report in merged-report.html