我的问题是,我希望 Cypress 库的期望断言超时,但似乎无法找到实现此目的的方法。
我尝试大幅增加 cypress.conf 中的全局超时;然而,这并没有奏效。
if ($widget.find('report-widget')) {
SVGCount++;
expect(barGraphsChange[index]).to.not.equal(undefined)
console.log(barGraphsChange, index)
cy.getBarGraphTotal(SVGCount, barGraphsChange[index])
}
如果没有超时,那么合理的解决方法也很好,谢谢!
另请注意: barGraphsChange[index] 正在在此阶段之前通过调用的自定义 Cypress 命令进行计算和分配。
最佳答案
您可以使用 should()
自定义您的期望,这将在指定的超时或全局 defaultCommandTimeout(如果未提供)内自动重试您的断言。
在你的情况下,我可能可以想象包装你的对象,指定超时,然后将你的逻辑传递给应该:
cy.wrap(someFunction, {timeout: 25000}).should(someFunction => expect(someFunction()).to.eq(someValue))
在此处了解更多信息:https://docs.cypress.io/api/commands/should.html#Function
关于javascript - 设置 Cypress 期望断言的超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57464806/