【发布时间】:2021-12-14 10:59:56
【问题描述】:
我有一个页面,其中有一个元素,如果向下滚动,它会加载新数据。
这大约需要 10 秒。
我写了以下测试:
it('Should display at least one facility in booking panel', (done) => {
function recursivelyScroll() {
cy.get(element)
.scrollTo('bottom');
cy.get(element)
.then($el => {
// If the element contains a loading class, we wait one second and scroll down again
if ($el.find(Loading).length > 0) {
setTimeout(recursivelyScroll, 1000);
} else {
// We are done waiting, no more loading is needed
// write test here
done();
}
});
}
recursivelyScroll();
});
赛普拉斯错误
在
4000ms之后超时。done()回调从未被调用!
根据赛普拉斯的说法,done() 方法的调用速度不够快,但他们没有关于如何延长 done 时间段的文档。此外,我可能不知道在赛普拉斯中创建这种滚动行为的更好方法。有简单的解决方法吗?
【问题讨论】:
标签: javascript typescript integration-testing cypress e2e-testing