我已经开始使用Detox为我们的react本地应用程序创建自动化UI测试(这里是在iOS上进行测试)。
我注意到脱毒(或Jest)随机超时。完全相同的测试有时会通过,但有时它会被卡住,不再继续运行测试。一旦jest结束,我将得到以下错误
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();
});我尝试使用“跟踪”标志来查看是否有任何细节说明为什么会被卡住。似乎有些invoke调用被跳过了,它试图在实际完成上一次测试之前执行下面的测试。
我不认为这是一个问题的测试本身,因为他们碰巧所有运行3/4次,我会说。
有人有这个问题吗?有办法解决吗?或者,如果某些东西冻结了,是否有重新启动测试集的方法?
谢谢!
发布于 2019-02-14 16:14:39
从waitFor的排毒文档中获取
注意:当到达超时时,waitFor不会抛出,相反,它只会继续到下一行。为了确保您的测试工作正常,您希望它们在下面的行中添加expect()
如果使用waitFor,则应该在等待之后将同一个元素的expect放在上面。也许可以尝试将测试调整到以下几个方面:
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项的情况下查找下一项。
https://stackoverflow.com/questions/54693619
复制相似问题