以下是我的测试结果
测试超时,无法在Cypress仪表板中显示。 如何为每个测试用例设置超时时间?
以下是我的测试结果
测试超时,无法在Cypress仪表板中显示。 如何为每个测试用例设置超时时间?
还可以应用特定于测试的超时,或使用
this.timeout(0)
来完全禁用超时。
it('should take less than 10 seconds', function() { // Note NOT arrow function
this.timeout(10000);
// test here
});
这有效是因为Mocha在Cypress中发挥了重要作用。
尝试这些简单的失败测试,它们通过Mocha done()
但从未调用它。它们会在指定的超时时间内失败。
it('should take less than 500ms', function(done) {
this.timeout(500);
});
it('should take less than 2s', function(done) {
this.timeout(2000);
});
it('should take less than 5s', function(done) {
this.timeout(5000);
});
this.timeout(1000)
并没有在 1 秒后结束我的测试,相反,命令继续运行超过了 1 秒的标记,并且任何花费超过 1 秒的命令都会失败,这正是设置默认命令超时所做的。也许 Cypress 没有正确地遵守这个规定? - ldam我认为你不能这样做。就我在文档中看到的,目前可以设置以下这些超时时间: