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

3
  • 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 '20 at 7:09
  • @srini thanks I will update the answer
    – PDHide
    Apr 21 '20 at 7:35
  • Thanks for useful information, What should be the command needs to b executed to run all the spec in integration folder and generate mochawesome report ?
    – Tej
    Aug 12 at 13:29
0

As previously answered, in version 4, mochawesome-merge removed the reportDir parameter. However, they replaced it with the files parameter. So, you do not need to resort to the using the > redirect style. Check out the "Migrating to v4" section of the mochawesome-merge Readme.

Their example shows replacing:

reportDir: "mochawesome-report",

with

files: ["./mochawesome-report/*.json"],

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.