0

I'm using Mochawesome with Cypress to generate reports.

I am consistently observing this error when I attempt to merge my individual Mochawesome test suite files into one combined report:

ERROR: Failed to merge reports

Error: Pattern --reportDir matched no report files

Here is how my package.json files looks:

{
  "name": "fe_automation",
  "version": "1.0.0",
  "description": "\"Sample Cypress UI tests\"",
  "main": "index.js",
  "scripts": {
      "clean:reports":"mkdir cypress\\reports\\ && mkdir cypress\\reports\\mocha\\ && mkdir cypress\\reports\\mochareports\\ ",
      "pretest":"npm run clean:reports",
      "scripts":"cypress run --spec 'cypress/integration/avitas/**/*' --headed",
      "merge-report":"mochawesome-merge --reportDir cypress/reports/mocha > cypress/reports/report.json",
      "generate-report":"marge cypress/reports/report.json -f report -o cypress/reports/mochareports",
      "posttest":"npm run merge-report && npm run generate-report",
      "test":"npm run scripts || npm run posttest"
  },
  "author": "Srini",
  "license": "ISC",
  "devDependencies": {
    "cypress": "^4.4.0",
    "mocha": "^7.1.1",
    "mochawesome": "^6.1.0"
  },
  "dependencies": {
    "cypress-multi-reporters": "^1.2.4",
    "mochawesome-merge": "^4.0.3"
  }
}

Here is how my cypress.json looks:

{
"reporter": "cypress-multi-reporters",
    "reporterOptions": {
        "reporterEnabled":"mochawesome",
        "mochawesomeReporterOptions":{
            "reportDir":"cypress/reports/mocha",
            "quite":true,
            "overwrite":false,
            "html":false,
            "json":true
        }
    }
}

All the tests get executed without an issue, but this error pops up during the report Merge process. I've referred online and no one has any concrete solution. Please help me out.

1

Which version of mochawesome-merge are you using , in the new new version reportdir flag is not supported.

You have to use:

"merge-report":"mochawesome-merge  cypress/reports/mocha/*.json> cypress/reports/report.json",

Where, cypress is the folder in your current directory.

Reference:

https://www.npmjs.com/package/mochawesome-merge

https://github.com/Antontelesh/mochawesome-merge#readme

| improve this answer | |
  • 1
    Yes this worked. Many thanks. I just removed the dots and made my merge-reports script loom like this: "merge-report":"mochawesome-merge cypress/reports/mocha/*.json> cypress/reports/report.json", . Works now. – srini Apr 21 at 7:09
  • @srini thanks I will update the answer – PDHide Apr 21 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.