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: Cannot read properties of undefined (reading 'length') #20545

Closed
darkhillreturns opened this issue Mar 9, 2022 · 6 comments
Closed
Labels
stage: awaiting response Potential fix was proposed; awaiting response

Comments

@darkhillreturns
Copy link

darkhillreturns commented Mar 9, 2022

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

@davidmunechika
Copy link
Contributor

Could you include a code example to reproduce this issue (possibly an example repo)? Unfortunately, if we don't have enough information to recreate the issue we will have to close this issue. Thanks!

@davidmunechika davidmunechika added the stage: needs information Not enough info to reproduce the issue label Mar 10, 2022
@nizam-uddin
Copy link

@darkhillreturns I had exactly the same error. I got mine fixed.

"mochawesome-report-generator": "^6.1.1" had a reporterOptions called inlineAssets which has been renamed to inline only.

Inside the cypress\integration directory, I had one file called constants.js to keep the login username and passwords.
The cypress\integration directory seems to be the wrong place for the constants.js file.
Moved it out of the cypress\integration directory and my problem was solved.

I'm not 100% sure about your setup but maybe this helps.

Thanks!

@davidmunechika davidmunechika added stage: awaiting response Potential fix was proposed; awaiting response and removed stage: needs information Not enough info to reproduce the issue labels Mar 14, 2022
@jaltmanQ
Copy link

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.

@rozzs74
Copy link

rozzs74 commented Mar 25, 2022

I replicate the same issue, followed @jaltmanQ reply fix the issue.

@quad5
Copy link

quad5 commented Apr 5, 2022

Might be the same issue as this which is recently resolved.

@davidmunechika
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: awaiting response Potential fix was proposed; awaiting response
Projects
None yet
Development

No branches or pull requests

6 participants