DEV Community

Discussion on: Using Mochawesome Reporter with Cypress

Collapse
 
madvic90 profile image
Madvic90

ERROR: Failed to merge reports - Mochawesome

I've installed the Mochawesome reporter and all the needed plugins. Whenever I try to run a folder it keeps giving me an ERROR that Cypress failed to merge the reports. It looks like that the script does not create a file in the folder mocha.

It only creates a report.json in Mochareports.
image

this is a part of my package.json.

{
"scripts": {
"cypress:open": "npm install && cypress open",
"cypress:open:local": "npm install && cypress open --env configFile=local",
"cypress:open:dev": "npm install && cypress open --env configFile=dev",
"cypress:open:tst": "npm install && cypress open --env configFile=tst",
"cypress:open:acc": "npm install && cypress open --env configFile=acc",
"cypress:run": "npm install && cypress run",
"cypress:run:local": "npm install && cypress run --browser chrome --headless --env configFile=local",
"cypress:run:tst": "npm install && cypress run --browser chrome --headless --env configFile=tst",
"cypress:run:acc": "npm install && cypress run --browser chrome --headless --env configFile=acc",
"cypress:run:acc:teampark": "npm install && cypress run --browser chrome --headless --env configFile=acc --spec cypress/integration/team_park.js --config video=false",
"clean:reports": "(if exist cypress\reports (rmdir /S /Q cypress\reports)) && mkdir cypress\reports && mkdir cypress\reports\mocha && mkdir cypress\reports\mochareports",
"pretest": "npm run clean:reports",
"scripts": "cypress run --spec cypress/integration/website/schooltrip/**/",
"combine-reports": "mochawesome-merge cypress/reports/mocha/.json > cypress/reports/report.json",
"generate-report": "marge cypress/reports/mochareports/report.json -f report -o cypress/reports/mochareports",
"posttest": "npm run combine-reports && npm run generate-report",
"test": "npm run scripts || npm run posttest"

Desired behavior:
What cypress needs to do according to all online explanation is to create a file in the Mocha and Mochareports and merge these files in order to get an HTML report.

Error given after a run:

@ posttest C:\Users\iessadeq\Desktop***l-cypress-tests-master
npm run combine-reports && npm run generate-report

@ combine-reports C:\Users\iessadeq\Desktop*******-cypress-tests-master
mochawesome-merge cypress/reports/mocha/.json > cypress/reports/report.json

ERROR: Failed to merge reports

Error: Pattern cypress/reports/mocha/*.json matched no report files

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ combine-reports: mochawesome-merge cypress/reports/mocha/*.json > cypress/reports/report.json
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ combine-reports script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\iessadeq\AppData\Roaming\npm-cache_logs\2020-07-10T13_54_21_097Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ posttest: npm run combine-reports && npm run generate-report
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ posttest script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\iessadeq\AppData\Roaming\npm-cache_logs\2020-07-10T13_54_21_243Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ test: npm run scripts || npm run posttest
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\iessadeq\AppData\Roaming\npm-cache_logs\2020-07-10T13_54_21_386Z-debug.log

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

I've tried several things without any succes.. Could anyone help please?

Versions
"devDependencies": {
"chance": "^1.1.0",
"cypress": "^4.7.0",
"cypress-file-upload": "^3.5.3",
"cypress-multi-reporters": "^1.4.0",
"lodash": "^4.17.15",
"mocha": "^8.0.1",
"mocha-junit-reporter": "^1.23.3",
"mochawesome": "^6.1.1",
"mochawesome-merge": "^4.1.0",
"mochawesome-report-generator": "^5.1.0"