cypress - 赛普拉斯错误 Cypress.moment.duration(时刻未定义)
问题描述
我正在使用 Cypress 并升级到 v8.3.1 版本,并且不断出现新错误。
Cannot read property 'duration' of undefined
Because this error occurred during a after all hook we are skipping all of the remaining tests.
地点:node_modules/@cypress/code-coverage/support.jsat line210
cy.task('coverageReport', null, {
timeout: Cypress.moment.duration(3, 'minutes').asMilliseconds(),
^
log: false
})
它说duration
找不到,因为Cypress.moment
不存在。
我检查了更改日志,他们将其删除:
Cypress.moment() has been removed. Please migrate to a different datetime formatter. See our recipe for example replacements. Addresses #8714.
但是由于我没有直接使用它,它在包含的代码覆盖范围内Cypress
,我不知道如何修复它。
解决方案
您不知何故获得了旧版本的@cypress/code-coverage。
也许您升级了赛普拉斯而不是代码覆盖包?
@cypress/code-coverage@3.2.0 - support.js
after(function generateReport() {
// when all tests finish, lets generate the coverage report
cy.task('coverageReport', {
timeout: Cypress.moment.duration(3, 'minutes').asMilliseconds()
})
})
@cypress/code-coverage@3.9.10 - support.js
after(function generateReport() {
...
cy.task('coverageReport', null, {
timeout: dayjs.duration(3, 'minutes').asMilliseconds(),
log: false
}).then((coverageReportFolder) => {
...
})
npm update @cypress/code-coverage
应该修复它
推荐阅读
- mqtt - 新订阅时未使用 Mosquitto 的 QoS 1 消息
- react-native - react-native 自定义滑块,使用 `diffClamp`
- arrays - 更改数组中的字符串值以将 VueJS 中的每个单词大写
- java - Google Cloud Talent API - Java:库丢失或示例已过时?
- sql - RPAD 数值
- javascript - useRef() 挂钩自定义组件
- reactjs - 在收到道具之前反应渲染
- c# - 无法使用实体框架创建控制器 - 运行所选代码生成器时出错“无法检索元数据
- ios - 无法在 watchOS 上使用 XCFramework
- c# - 如何硬编码身份用户登录?