发生故障时重新启动治具

时间:2019-04-01 17:50:10

标签: automated-tests e2e-testing web-testing testcafe

我编写了一个测试,该测试通过了95%的时间,但未通过其他5%的测试。我仍然不知道为什么它会失败(我的猜测是组件未正确呈现)。

我实现了页面重新加载调用,以重新加载页面并重试,但这不是很可靠。

万一发生故障,重启夹具的最佳方法是什么?

这是一个示例测试,有意无法模拟大多数情况下都能正常工作的选择器,但有时会失败。

import { Selector } from 'testcafe';

const URL = 'https://www.youtube.com/watch?v=RWQtB6Xv01Q';

fixture `Portal Experience playback`
  .page `${URL}`;

test('Testing YouTube', async t => {
  await t.click(Selector('.wrong-selector')); // to emulate my unstable test
});

结果

✖ Testing YouTube

   1) The specified selector does not match any element in the DOM tree.

是否可以将测试放入for循环中,并在测试通过的情况下使其脱离循环?

1 个答案:

答案 0 :(得分:3)

quarantine mode用于此目的。在这种模式下,TestCafe将再次重新启动失败的测试,直到它通过或失败3次为止,并且仅在失败3次之后才认为失败。在本文中获得有关隔离模式的更多详细信息:Quarantine Mode

相关问题