Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when using custom reporter #3537

Closed
gustawx opened this issue Feb 20, 2019 · 34 comments · Fixed by #6951
Closed

TypeError when using custom reporter #3537

gustawx opened this issue Feb 20, 2019 · 34 comments · Fixed by #6951

Comments

@gustawx
Copy link

gustawx commented Feb 20, 2019

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"
@jennifer-shehane
Copy link
Member

  • Can you provide the exact command you are running to run Cypress, including all arguments?

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.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Feb 20, 2019
@gustawx
Copy link
Author

gustawx commented Feb 20, 2019

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:

TypeError: Cannot read property 'failures' of undefined
...

@jennifer-shehane
Copy link
Member

Yeah, I haven't thoroughly looked through Mocha 6's changelog to see if they've made a breaking change regarding this or if this is a bug on their part. Or maybe mochaawesome needs to update their code to handle Mocha 6. 😕

@cypress-bot cypress-bot bot added stage: needs investigating Someone from Cypress needs to look at this and removed stage: needs information Not enough info to reproduce the issue labels Feb 20, 2019
@isdzulqor
Copy link

isdzulqor commented Mar 6, 2019

got this error too with this following details

{
  "name": "coba-bos-cypress",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "cy:run": "node_modules/cypress/bin/cypress run",
    "cleanup": "rm -fr mochawesome-report",
    "merge_reports": "mochawesome-merge --reportDir mochawesome-report > mochawesome-report/output.json",
    "generate_mochawesome_report": "marge mochawesome-report/output.json",
    "e2e_mochawesome": "npm run cleanup && cypress run && npm run merge_reports && npm run generate_mochawesome_report"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cypress": "^3.1.5"
  },
  "devDependencies": {
    "mocha": "^6.0.2",
    "mochawesome": "^3.1.1",
    "mochawesome-merge": "^1.0.7",
    "mochawesome-report-generator": "^3.1.5"
  }
}

@arendjantetteroo
Copy link
Contributor

arendjantetteroo commented Mar 11, 2019

We use the mocha-junit-reporter with mocha-multi-reporters but not the mochawesome one, so this seems a problem in a BC break in mocha 6 itself. Will downgrade to 5.2 for the moment.

michaelleeallen/mocha-junit-reporter#78

@YOU54F
Copy link
Contributor

YOU54F commented Mar 17, 2019

Hi,

I have 2 PR's tracking this upgrade to mocha 6, I use cypress & mochawesome for reporting.

They have circleci runs associated with them, in case anyone wants to track the change as the other dependancies update. I haven't had a chance to look into this yet in much detail

YOU54F/template-cypress-docker-typescript#15
https://github.com/YOU54F/cypressio-docker/pull/12

@YOU54F
Copy link
Contributor

YOU54F commented Mar 27, 2019

Just fixed this and proposed the following 2 PR's

stanleyhlng/mocha-multi-reporters#58
michaelleeallen/mocha-junit-reporter#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

    "mocha": "^6.0.0",
    "mocha-junit-reporter": "YOU54F/mocha-junit-reporter#master",
    "mocha-multi-reporters": "YOU54F/mocha-multi-reporters#master",

@jennifer-shehane jennifer-shehane added stage: awaiting external fix A 3rd party bug in Cypress - awaiting release and removed stage: needs investigating Someone from Cypress needs to look at this labels Mar 29, 2019
@vidhyaSoundararajan
Copy link

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:

TypeError: Cannot read property 'failures' of undefined
...

@YOU54F
Copy link
Contributor

YOU54F commented May 8, 2019

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. (tested with mocha 6.0.0 / latest and 5.2.0)

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-reporters
npm i cypress-multi-reporters

in reporterOpts.json

{
  "reporterEnabled": "mocha-junit-reporters, mochawesome",
  "mochaJunitReportersReporterOptions": {
    "mochaFile": "cypress/reports/junit/test_results[hash].xml",
    "toConsole": false
  },
  "mochawesomeReporterOptions": {
    "reportDir": "cypress/reports/mocha",
    "quiet": true,
    "overwrite": false,
    "html": false,
    "json": true
  }
} 

in cypress.json

{
  ...
  "reporter": "cypress-multi-reporters",
  "reporterOptions": {
    "configFile": "reporterOpts.json"
  }

See https://github.com/YOU54F/cypress-docker-typescript/pull/22/files for this fix applied, I have teste

Hopefully the PR's will be merged in the source repo's soon but for now, enjoy

@executeautomation
Copy link

This issue still happens in latest version 3.3.0 as well !

@YOU54F
Copy link
Contributor

YOU54F commented May 25, 2019

@executeautomation It's not an issue in Cypress, it was a breaking change in Mocha, I fixed it and have just performed a run with Mocha 6>, Cypress 3.3.1 and my forks npm i mocha-junit-reporters & npm i cypress-multi-reporters and it passed successfully - https://circleci.com/gh/YOU54F/cypress-docker-typescript/180

 "dependencies": {
    "cypress": "^3.3.1",
    "mocha": "^6.1.4",
    "mocha-junit-reporters": "^1.23.0",
    "cypress-multi-reporters": "^1.1.9",
    "mochawesome": "^3.1.1",
    "mochawesome-merge": "^1.0.7",
    "mochawesome-report-generator": "^3.1.5",
    "cypress-slack-reporter": "0.2.6",
  }

@executeautomation
Copy link

Wow thats cool @YOU54F , great to fix the issue and hopefully it will be fixed in cypress-multi-reporters and mocha-junit-reporters as well.

Thanks,
Karthik KK

@jennifer-shehane
Copy link
Member

Closing since this is an external issue.

@alexbjorlig
Copy link

alexbjorlig commented Jun 3, 2019

@YOU54F we were using this setup:

 "mocha": "^6.0.0",
 "mocha-junit-reporter": "YOU54F/mocha-junit-reporter#master",
 "mocha-multi-reporters": "YOU54F/mocha-multi-reporters#master",

But your repository mocha-multi-reporters seems to have changed name or removed?

@jennifer-shehane
Copy link
Member

mocha-multi-reporters has never been maintained by Cypress. It is under another person's repository and npm package.

@alexbjorlig
Copy link

@jennifer-shehane sorry for the misunderstanding. I tried to highlight @YOU54F's name, it was a question to him on behalf of the cypress community using moche multi reporters 🤓

I think he renamed the package from mocha-multi-reporters to cypress-multi-reporters. Our e2e cypress tests started failing this morning because the repo could not be found. I mention it here so it can hopefully help other people using cypress and multi reporters in their dev flow.

@YOU54F
Copy link
Contributor

YOU54F commented Jun 3, 2019

@YOU54F we were using this setup:

 "mocha": "^6.0.0",
 "mocha-junit-reporter": "YOU54F/mocha-junit-reporter#master",
 "mocha-multi-reporters": "YOU54F/mocha-multi-reporters#master",

But your repository mocha-multi-reporters seems to have changed name or removed?

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

npm i cypress-multi-reporters
npm i mocha-junit-reporters

@alexbjorlig
Copy link

@YOU54F awesome, great work and fast response 🔥 We just confirmed that it works. Thanks for making the world a better place 🙌

@Dksoni81291
Copy link

Working properly with this combination:

"cypress": "^3.5.0",
"mocha": "^6.2.2",
"mochawesome": "^4.1.0"
`

@jennifer-shehane jennifer-shehane removed the stage: awaiting external fix A 3rd party bug in Cypress - awaiting release label Jan 3, 2020
@MrBokeh
Copy link

MrBokeh commented Feb 2, 2020

Mocha 5.2.0 won't have this issue, only the latest Mocha 6.x and 7.x are still having this same issue...

@keselva
Copy link

keselva commented Feb 12, 2020

"mocha": "^5.2.0",
"mocha-junit-reporter": "^1.18.0",
"mocha-multi-reporters": "^1.1.7",
"mochawesome": "^4.0.1",
"mochawesome-merge": "^2.0.1",
"mochawesome-report-generator": "^4.0.1"

am getting below error,
ERROR: Failed to merge reports
TypeError: Cannot read property 'filter' of undefined
at report (/Users/admin/checker/node_modules/mochawesome-merge/lib/index.js:44:18)
at Array.map ()
at items (/Users/admin/checker/node_modules/mochawesome-merge/lib/utils.js:3:46)
at merge (/Users/admin/checker/node_modules/mochawesome-merge/lib/index.js:58:18)

@kuceb
Copy link
Contributor

kuceb commented Apr 6, 2020

reopening since this is a problem we can potentially fix, we shouldn't require users to install a specific mocha version

@kuceb kuceb changed the title TypeError when using mochawesome reporter TypeError when using custom reporter Apr 6, 2020
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Apr 7, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Apr 22, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 22, 2020

The code for this is done in cypress-io/cypress#6951, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 28, 2020

Released in 4.5.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.5.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Apr 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.