我已经开始使用Detox为我们的本机应用程序创建自动化UI测试(此处为iOS上的测试)。
我注意到排毒(或开玩笑)随机超时。完全相同的测试有时会通过,但另一些时间会卡住,无法继续运行测试。开玩笑的超时结束后,我得到以下错误
Timeout - Async callback was not invoked within the 40000ms timeout specified by jest.setTimeout.
47 | });
48 | describe('when the user taps on the payment history tab', () => {
> 49 | it('should go on the payment history view', async () => {
at Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:92:20)
at Suite.<anonymous> (e2e/tests/loans/index.test.js:49:7)
我的测试之一如下:
it('should go on the payment history view', async () => {
await element(by.id('product-tab-2')).tap();
await waitFor(element(by.id('product-payment-history-1')))
.toBeVisible()
.withTimeout(5000);
await expect(element(by.id('product-payment-history-1'))).toBeVisible();
});
我尝试使用“ trace”标志来查看是否有任何有关其卡住原因的详细信息。似乎有些invoke
调用被跳过了,并在实际完成上一个测试之前尝试执行以下测试。
我认为测试本身不是问题,因为它们恰好全部运行了3次,我说了3次。
有人遇到这个问题吗?有办法解决吗?还是有办法在冻结时重新启动测试集?
谢谢!
答案 0 :(得分:0)
摘自waitFor的排毒文档
注意:waitFor不会在达到超时时抛出,而是 只需继续下一行。确保您的测试能像您一样工作 希望他们在以下行中添加Expect()
如果使用waitFor,则由于上述原因,应在等待之后放置对相同元素的期望值。也许尝试将测试调整为以下内容:
it('should go on the payment history view', async () => {
await element(by.id('product-tab-2')).tap();
await waitFor(element(by.id('product-payment-history-1')))
.toBeVisible()
.withTimeout(5000);
await expect(element(by.id('product-payment-history-1'))).toBeVisible();
await expect(element(by.id('product-payment-history'))).toBeVisible();
});
这将避免测试继续进行并寻找下一个项目,而不会显示waitFor项目