在没有更改测试或测试环境的情况下,成功运行到2019年2月18日的cypress.io测试现在失败并出现错误。
Cypress.io是版本3.1.5
测试由jenkinsfile运行:
sh "npx cypress run --browser chrome --reporter mocha-multi-reporters --reporter-options configFile=config-v1-smoke.json --spec \"cypress/integration/smoke/*.js\""
错误是:
TypeError: Cannot read property 'passes' of undefined
at Spec.Base.epilogue (/var/jenkins_home/workspace/svn_ci/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 (/var/jenkins_home/.cache/Cypress/3.1.5/Cypress/resources/app/packages/server/lib/reporter.js:239:55)
at Object.server.startWebsockets.onMocha (/var/jenkins_home/.cache/Cypress/3.1.5/Cypress/resources/app/packages/server/lib/project.js:296:22)
at Socket.<anonymous> (/var/jenkins_home/.cache/Cypress/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 /var/jenkins_home/.cache/Cypress/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 (/var/jenkins_home/workspace/svn_ci/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 (/var/jenkins_home/.cache/Cypress/3.1.5/Cypress/resources/app/packages/server/lib/reporter.js:239:55)
at Object.server.startWebsockets.onMocha (/var/jenkins_home/.cache/Cypress/3.1.5/Cypress/resources/app/packages/server/lib/project.js:296:22)
at Socket.<anonymous> (/var/jenkins_home/.cache/Cypress/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 /var/jenkins_home/.cache/Cypress/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:18
0:9)
答案 0 :(得分:5)
mocha@6.0.0已于2019-02-18发行。 通过将mocha从降级到最新版本mocha@5.2.0,可以缓解此问题。使用mocha@5.2.0,可以按照--spec中的指定运行正确的cypress.io测试集。
mocha@6.0.0中的某些内容正在通过mocha报告为cypress.io创建测试规范问题。
答案 1 :(得分:0)
华盛顿关于全球问题的评论不正确。 Mocha 6需要实例化统计收集器。
我现在已经更新,测试并发布了更新的模块,这些模块可以用mocha 6修复此问题,但仍保持与mocha 5和更早版本的向后兼容性。
https://www.npmjs.com/package/cypress-multi-reporters https://www.npmjs.com/package/mocha-junit-reporters
Example against Mocha 5 Example against Mocha 6
所需的更改很小
npm i mocha-junit-reporters
npm i cypress-multi-reporters
在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
}
}
在cypress.json中
{
...
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"configFile": "reporterOpts.json"
}
请参见https://github.com/YOU54F/cypress-docker-typescript/pull/22/files
希望PR可以很快合并到源仓库中,但现在享受吧