michaelleeallen / mocha-junit-reporter

A JUnit XML reporter for mocha.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"TypeError: testcase.testcase[0]._attr.time.toFixed is not a function" fails CI pipelines randomly

dawid-bobowski opened this issue · comments

Current behaviour:

TypeError is thrown randomly when running Cypress tests in Jenkins pipeline which fails the build before all tests are finished:

09:05:20  TypeError: testcase.testcase[0]._attr.time.toFixed is not a function
09:05:20      at /home/node/node_modules/mocha-junit-reporter/index.js:438:73
09:05:20      at Array.forEach (<anonymous>:null:null)
09:05:20      at /home/node/node_modules/mocha-junit-reporter/index.js:433:12
09:05:20      at Array.forEach (<anonymous>:null:null)
09:05:20      at MochaJUnitReporter.getXml (/home/node/node_modules/mocha-junit-reporter/index.js:417:14)
09:05:20      at MochaJUnitReporter.flush (/home/node/node_modules/mocha-junit-reporter/index.js:395:20)
09:05:20      at MochaJUnitReporter.<anonymous> (/home/node/node_modules/mocha-junit-reporter/index.js:272:10)
09:05:20      at Runner.emit (events.js:327:22)
09:05:20      at Reporter.emit (/root/.cache/Cypress/8.3.0/Cypress/resources/app/packages/server/lib/reporter.js:333:46)
09:05:20      at ProjectBase.<anonymous> (/root/.cache/Cypress/8.3.0/Cypress/resources/app/packages/server/lib/project-base.js:449:34)
09:05:20      at Generator.next (<anonymous>:null:null)
09:05:20      at /root/.cache/Cypress/8.3.0/Cypress/resources/app/packages/server/node_modules/tslib/tslib.js:117:75
09:05:20      at new Promise (<anonymous>:null:null)
09:05:20      at Object.__awaiter (/root/.cache/Cypress/8.3.0/Cypress/resources/app/packages/server/node_modules/tslib/tslib.js:113:16)
09:05:20      at Object.onMocha (/root/.cache/Cypress/8.3.0/Cypress/resources/app/packages/server/lib/project-base.js:442:51)
09:05:20      at Socket.<anonymous> (/root/.cache/Cypress/8.3.0/Cypress/resources/app/packages/server/lib/socket-base.js:213:40)
09:05:20      at Socket.emit (events.js:315:20)
09:05:20      at Socket.emitUntyped (/root/.cache/Cypress/8.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/typed-events.js:69:22)
09:05:20      at /root/.cache/Cypress/8.3.0/Cypress/resources/app/packages/socket/node_modules/socket.io/dist/socket.js:428:39
09:05:20      at processTicksAndRejections (internal/process/task_queues.js:75:11)

Expected behaviour:

All of Cypress tests in Jenkins pipeline are run properly.

Cypress version:

8.3.0
It was also reported with other versions: cypress-io/cypress#18970

Possible solution:

Suggested by @halfninja in cypress-io/cypress#18970 (comment)

I'm having the exact same issue with Cypress 10.3.