如何减慢 TestCafe 中的测试执行速度?

Mat*_*rše 5 testing automation automated-tests e2e-testing testcafe

我想检查另一位开发人员编写的 UI 测试执行情况。速度太快了,我的眼睛和大脑无法捕捉到正在发生的事情。

如何减慢 TestCafe 中测试的执行速度?

Mat*_*rše 8

在更加关注文档后找到了答案

TestCafe 提供更改测试速度的功能。测试全速执行,操作和断言之间的延迟最小,这使得测试运行时很难发现问题。

要减慢测试速度,请使用 --speed CLI 标志。您可以使用 1 到 0.01 之间的值。

testcafe chrome ./my-tests --speed 0.1
Run Code Online (Sandbox Code Playgroud)


Ram*_*ath 3

另一种方法是在 beforeEach 中使用 setTestSpeed。这是一个代码片段:

fixture`Test`
    .page`http://www.google.com`

    .before(async t => {
    })

    .beforeEach(async t => {
        await t.setTestSpeed(0.3)
        await t.maximizeWindow()
    })

test("hello", async t => {

});
Run Code Online (Sandbox Code Playgroud)