cypress: TypeError when using custom reporter
Current behavior:
After running cypress with --reporter mochawesome I’m getting exception:
TypeError: Cannot read property 'passes' of undefined
at Spec.Base.epilogue (<path>\node_modules\mocha\lib\reporters\base.js:318:25)
at Object.onceWrapper (events.js:316:30)
at emitOne (events.js:120:20)
at Runner.emit (events.js:210:7)
at Reporter.emit (<path>\AppData\Local\Cypress\Cache\3.1.5\Cypress\resources\app\packages\server\lib\reporter.js:239:55)
at Object.server.startWebsockets.onMocha (<path>\AppData\Local\Cypress\Cache\3.1.5\Cypress\resources\app\packages\server\lib\project.js:296:22)
at Socket.<anonymous> (<path>\AppData\Local\Cypress\Cache\3.1.5\Cypress\resources\app\packages\server\lib\socket.js:237:36)
at emitTwo (events.js:125:13)
at Socket.emit (events.js:213:7)
at <path>\AppData\Local\Cypress\Cache\3.1.5\Cypress\resources\app\packages\socket\node_modules\socket.io\lib\socket.js:503:12
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
TypeError: Cannot read property 'passes' of undefined
at Spec.Base.epilogue (<path>\node_modules\mocha\lib\reporters\base.js:318:25)
at Object.onceWrapper (events.js:316:30)
at emitOne (events.js:120:20)
at Runner.emit (events.js:210:7)
at Reporter.emit (<path>\AppData\Local\Cypress\Cache\3.1.5\Cypress\resources\app\packages\server\lib\reporter.js:239:55)
at Object.server.startWebsockets.onMocha (<path>\AppData\Local\Cypress\Cache\3.1.5\Cypress\resources\app\packages\server\lib\project.js:296:22)
at Socket.<anonymous> (<path>\AppData\Local\Cypress\Cache\3.1.5\Cypress\resources\app\packages\server\lib\socket.js:237:36)
at emitTwo (events.js:125:13)
at Socket.emit (events.js:213:7)
at <path>\AppData\Local\Cypress\Cache\3.1.5\Cypress\resources\app\packages\socket\node_modules\socket.io\lib\socket.js:503:12
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
Desired behavior:
Report is generated
Steps to reproduce: (app code and test code)
Set up according to documentation
Versions
"mocha": "^6.0.0",
"mochawesome": "^3.1.1",
"cypress": "^3.1.5"
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 22
- Comments: 34 (18 by maintainers)
Commits related to this issue
- fix: e2e test fail https://github.com/cypress-io/cypress/issues/3537 — committed to Thirosue/sample-vuejs-front by Thirosue 5 years ago
@dauledk - no worries chap, some instructions I wrote that may help others,
I’ve now updated, tested and released updated modules that fix this with mocha 6, but also retains backwards compatibility with mocha 5 and earlier versions.
https://www.npmjs.com/package/cypress-multi-reporters https://www.npmjs.com/package/mocha-junit-reporters
Example against Mocha 5 Example against Mocha 6
the changes required are minimal
npm i mocha-junit-reportersnpm i cypress-multi-reportersin reporterOpts.json
in cypress.json
See https://github.com/YOU54F/cypress-docker-typescript/pull/22/files
Hopefully the PR’s will be merged in the source repo’s soon but for now, enjoy
Also, I notice that mocha 6.0.0 just released 2 days ago. Can you try installing
"mocha": "5.2.0"to see if that works? I’d like to narrow down whether this is an issue with their newest release.Thank you for quick answer. With mocha 5.2.0 it works fine, thank you. I checked mocha-junit-reporter and the error is similar:
Just fixed this and proposed the following 2 PR’s
https://github.com/stanleyhlng/mocha-multi-reporters/pull/58 https://github.com/michaelleeallen/mocha-junit-reporter/pull/80
My branch tracking the changes, with failing builds with mocha 6 pre and post fix is here
https://github.com/YOU54F/cypressio-docker-typescript/pull/15/files
If you do want to move up to mocha 6, you can pull my forked branch in the interim, whilst we wait for the maintainers of the source repo to review/merge/release the PR
Hey chap
Apologies, I deleted the fork and released it as https://github.com/YOU54F/cypress-multi-reporters as the main repository isn’t being maintained
They are both published to npm with updated dependencies
My fix for mocha-junit-reporter has now been merged and is available in the newly released v1.23.0
https://github.com/michaelleeallen/mocha-junit-reporter/releases/tag/v1.23.0
@YOU54F Thanks alot ! your solution worked !
Thanks mate, you are humble enough to accept the credit for work you have done!
Cheers matey, glad to help where I can. I’ve consumed so many peoples projects over time, that I am only standing on the shoulders on giants. It has been a great learning exercise in coding for me as a software tester getting into the world of dev 😃
I am getting the below error while merging the mochawesome report. Command $ npx mochawesome-merge — reportDir mochawesome-report > mochawesome-report/output.json
Also props to the Cypress team for all their hard work and for supporting the OSS community!
Thank you @YOU54F, the example you showed works pretty much expected, kudos to your work and thanks for making this happen, I will surely mention you in my course 🙌
@YOU54F awesome, great work and fast response 🔥 We just confirmed that it works. Thanks for making the world a better place 🙌
mocha-multi-reportershas never been maintained by Cypress. It is under another person’s repository and npm package.@YOU54F we were using this setup:
But your repository
mocha-multi-reportersseems to have changed name or removed?