失败时重新启动夹具

问题描述 投票:2回答:1

我写了一个测试,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循环中并在测试通过时将其从循环中分离出来?

automated-tests e2e-testing web-testing testcafe
1个回答
3
投票

quarantine mode就是为了这个目的。在此模式下,TestCafe将再次重新启动失败的测试,直到它通过或失败3次,并且只有在失败3次时才会认为失败。在本文中获取有关隔离模式的更多详细信息:Quarantine Mode

© www.soinside.com 2019 - 2024. All rights reserved.