首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自动排毒测试随机超时

自动排毒测试随机超时
EN

Stack Overflow用户
提问于 2019-02-14 15:16:08
回答 1查看 1.4K关注 0票数 1

我已经开始使用Detox为我们的react本地应用程序创建自动化UI测试(这里是在iOS上进行测试)。

我注意到脱毒(或Jest)随机超时。完全相同的测试有时会通过,但有时它会被卡住,不再继续运行测试。一旦jest结束,我将得到以下错误

代码语言:javascript
复制
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)

我的一个测试看起来是这样的:

代码语言:javascript
复制
  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();
  });

我尝试使用“跟踪”标志来查看是否有任何细节说明为什么会被卡住。似乎有些invoke调用被跳过了,它试图在实际完成上一次测试之前执行下面的测试。

我不认为这是一个问题的测试本身,因为他们碰巧所有运行3/4次,我会说。

有人有这个问题吗?有办法解决吗?或者,如果某些东西冻结了,是否有重新启动测试集的方法?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2019-02-14 16:14:39

waitFor的排毒文档中获取

注意:当到达超时时,waitFor不会抛出,相反,它只会继续到下一行。为了确保您的测试工作正常,您希望它们在下面的行中添加expect()

如果使用waitFor,则应该在等待之后将同一个元素的expect放在上面。也许可以尝试将测试调整到以下几个方面:

代码语言:javascript
复制
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项的情况下查找下一项。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54693619

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档