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 properties of undefined (reading 'length')

See original GitHub issue

Current behavior

When running mochawesome as reporter, it shows error

[mochawesome] Problem with mochawesome: TypeError: Cannot read properties of undefined (reading 'length')
    at Runner.<anonymous> (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome\src\mochawesome.js:164:30)
    at Runner.emit (node:events:406:35)
    at Reporter.emit (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\reporter.js:362:46) 
    at ProjectBase.<anonymous> (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\project-base.js:460:34)
    at Generator.next (<anonymous>:null:null)
    at C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\node_modules\tslib\tslib.js:117:75
    at new Promise (<anonymous>:null:null)
    at __awaiter (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\node_modules\tslib\tslib.js:113:16)
    at Object.onMocha (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\project-base.js:453:65)
    at Socket.<anonymous> (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\socket-base.js:213:40)
    at Socket.emit (node:events:394:28)
    at Socket.emitUntyped (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\typed-events.js:69:22)
    at C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\socket.js:428:39
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

TypeError: Cannot read properties of undefined (reading 'results')
    at getFilename (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome-report-generator\lib\main.js:132:47)
    at getOptions (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome-report-generator\lib\main.js:150:18)
    at prepare (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome-report-generator\lib\main.js:269:23)
    at Object.create (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome-report-generator\lib\main.js:303:18)
    at done (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome\src\mochawesome.js:36:6)
    at Mochawesome.done (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome\src\mochawesome.js:103:5)
    at C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\cypress-multi-reporters\lib\MultiReporters.js:136:18  
    at Array.forEach (<anonymous>:null:null)
    at MultiReporters.done (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\cypress-multi-reporters\lib\MultiReporters.js:135:30)
    at C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\reporter.js:430:30
    at Promise.cancellationExecute [as _execute] (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\debuggability.js:406:9)
    at Promise._resolveFromExecutor (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:518:18)
    at new Promise (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:103:10)
    at Reporter.end (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\reporter.js:429:14)  
    at ProjectBase.<anonymous> (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\project-base.js:463:70)
    at Generator.next (<anonymous>:null:null)
    at C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\node_modules\tslib\tslib.js:117:75
    at new Promise (<anonymous>:null:null)
    at __awaiter (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\node_modules\tslib\tslib.js:113:16)
    at Object.onMocha (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\project-base.js:453:65)
    at Socket.<anonymous> (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\socket-base.js:213:40)
    at Socket.emit (node:events:394:28)
    at Socket.emitUntyped (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\typed-events.js:69:22)
    at C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\socket.js:428:39
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

TypeError: Cannot read properties of undefined (reading 'results')
    at getFilename (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome-report-generator\lib\main.js:132:47)
    at getOptions (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome-report-generator\lib\main.js:150:18)
    at prepare (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome-report-generator\lib\main.js:269:23)
    at Object.create (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome-report-generator\lib\main.js:303:18)
    at done (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome\src\mochawesome.js:36:6)
    at Mochawesome.done (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\mochawesome\src\mochawesome.js:103:5)
    at C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\cypress-multi-reporters\lib\MultiReporters.js:136:18  
    at Array.forEach (<anonymous>:null:null)
    at MultiReporters.done (C:\Users\admin\OneDrive\Documents\Automation\PlatformOneQA\node_modules\cypress-multi-reporters\lib\MultiReporters.js:135:30)
    at C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\reporter.js:430:30
    at Promise.cancellationExecute [as _execute] (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\debuggability.js:406:9)
    at Promise._resolveFromExecutor (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:518:18)
    at new Promise (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\promise.js:103:10)
    at Reporter.end (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\reporter.js:429:14)  
    at ProjectBase.<anonymous> (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\project-base.js:463:70)
    at Generator.next (<anonymous>:null:null)
    at C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\node_modules\tslib\tslib.js:117:75
    at new Promise (<anonymous>:null:null)
    at __awaiter (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\node_modules\tslib\tslib.js:113:16)
    at Object.onMocha (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\project-base.js:453:65)
    at Socket.<anonymous> (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\server\lib\socket-base.js:213:40)
    at Socket.emit (node:events:394:28)
    at Socket.emitUntyped (C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\typed-events.js:69:22)
    at C:\Users\admin\AppData\Local\Cypress\Cache\9.5.1\Cypress\resources\app\packages\socket\node_modules\socket.io\dist\socket.js:428:39
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

Desired behavior

Should run and generate report

Test code to reproduce

"devDependencies": {
    "cypress": "^9.5.1",
    "cypress-multi-reporters": "^1.5.0",
    "dev-cli": "^0.0.0",
    "junit-merge": "^2.0.0",
    "mocha": "^9.2.1",
    "mochawesome": "^7.1.2",
    "mochawesome-merge": "^4.2.1",
    "mochawesome-report-generator": "^6.1.1"
  },
  "dependencies": {
    "mocha-junit-reporter": "^2.0.2",
    "save-dev": "^0.0.1-security"
  }
}

Cypress Version

9.5.1

Other

No response

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
jaltmanQcommented, Mar 23, 2022

Just ran into the same issue, but it appears to be an issue in mochawesome. I had a utility file with no tests in my cypress/integration folder that was causing the problem. Moving it to a different folder fixed the issue.

1reaction
davidmunechikacommented, Apr 6, 2022

Closing this issue because it appears to be an issue with mochawesome rather than Cypress. Let me know if you are still experiencing a problem and I will be happy to reopen this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read properties of undefined (reading 'length') - TrackJS
TypeError is a subset of JavaScript Error that is thrown when code attempts to do something that does not exist on the target...
Read more >
TypeError: Cannot read property 'length' of Undefined in JS
The "Cannot read property 'length' of undefined" error occurs when accessing the length property on an undefined value. To solve the error, make...
Read more >
Typeerror: Cannot Read Property 'length' of Undefined
A typeerror length of undefined can indicate that the actual type of an operand is different from the expected type. This error can...
Read more >
[SOLVED] Cannot Read Property 'length' of Undefined in JS
4 Quick Fixes for the “Cannot Read Property 'length' of Undefined” Error in JavaScript · 1. Use an if Statement · 2. Use...
Read more >
Cannot read property length of undefined - Stack Overflow
The error means that what ever element is returned by getElementById('WallSearch') , it does not have a value property. Every form field has...
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