question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'passes' of undefined

See original GitHub issue

I’ve installed the latest mocha, mochawesome, cypress etc,but when i run ‘npm test’,No test report was generated. package.json:

{
  "name": "cypresstest",
  "version": "1.0.0",
  "main": "index.js",
  "dependencies": {
    "cypress": "^3.1.5"
  },
  "devDependencies": {
    "mocha": "^6.0.1",
    "mochawesome": "^3.1.1",
    "mochawesome-merge": "^1.0.5",
    "mochawesome-report-generator": "^3.1.5"
  },
  "scripts": {
    "cypress:open": "cypress open",
    "test": "cypress run --reporter mochawesome"
  },
  "author": "",
  "license": "ISC",
  "description": ""
}

exception:

TypeError: Cannot read property 'passes' of undefined
    at Spec.Base.epilogue (/Users/tianyawei/Applications/CypressTest/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 (/Users/tianyawei/Library/Caches/Cypress/3.1.5/Cypress.app/Contents/Resources/app/packages/server/lib/reporter.js:239:55)
    at Object.server.startWebsockets.onMocha (/Users/tianyawei/Library/Caches/Cypress/3.1.5/Cypress.app/Contents/Resources/app/packages/server/lib/project.js:296:22)
    at Socket.<anonymous> (/Users/tianyawei/Library/Caches/Cypress/3.1.5/Cypress.app/Contents/Resources/app/packages/server/lib/socket.js:237:36)
    at emitTwo (events.js:125:13)
    at Socket.emit (events.js:213:7)
    at /Users/tianyawei/Library/Caches/Cypress/3.1.5/Cypress.app/Contents/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 (/Users/tianyawei/Applications/CypressTest/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 (/Users/tianyawei/Library/Caches/Cypress/3.1.5/Cypress.app/Contents/Resources/app/packages/server/lib/reporter.js:239:55)
    at Object.server.startWebsockets.onMocha (/Users/tianyawei/Library/Caches/Cypress/3.1.5/Cypress.app/Contents/Resources/app/packages/server/lib/project.js:296:22)
    at Socket.<anonymous> (/Users/tianyawei/Library/Caches/Cypress/3.1.5/Cypress.app/Contents/Resources/app/packages/server/lib/socket.js:237:36)
    at emitTwo (events.js:125:13)
    at Socket.emit (events.js:213:7)
    at /Users/tianyawei/Library/Caches/Cypress/3.1.5/Cypress.app/Contents/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)

npm ERR! Test failed.  See above for more details.
tianyaweideMacBook-Pro:CypressTest tianyawei$ 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
YOU54Fcommented, Jun 4, 2019

Updated instructions

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-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

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

1reaction
stevenvanryckeghemcommented, Feb 24, 2020

Any news on this matter? Meanwhile Cypress 4.0 has been released and they now require Mocha 7.0.1 (https://docs.cypress.io/guides/references/migration-guide.html#Migrating-to-Cypress-4-0)

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'passes' of undefined #4304
Desired behavior: Generated Html reports from running the tests. Steps to reproduce: (app code and test code). I have followed everything from ...
Read more >
Cannot read property 'passes' of undefined using Cypress ...
javascript - Got TypeError: Cannot read property 'passes' of undefined using Cypress when generating mochawesome report - Stack Overflow. Stack ...
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >
How to Prevent the Error: Cannot Read Property '0' of Undefined
A guide on how to prevent the error "cannot Read Property '0' of Undefined", covering techniques such as try, catch, using const over...
Read more >
M220JS, Ticket:Connection TypeError: Cannot read property ...
I am starting M220JS and got to the ticket:connection at the end of Chapter 0. ... TypeError: Cannot read property 'close' of undefined....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found