Testcafe:获取错误:无法隐式解析测试运行

Pol*_*oly 3 testing automated-tests typescript e2e-testing testcafe

我正在 testcafe 中编写脚本来解析响应并验证,该响应包含必需的文本,但出现错误:无法在应执行测试控制器操作的上下文中隐式解析测试运行。改用测试函数的 't' 参数。

test ('Control server info', async () => {

    await t
      .click(infoserver.serverinfoButton)
      .click(infoserver.getInfoButton)

    await infoserver.resultText.value.then( async (res) => {
        const infoParse = JSON.parse(res);
        console.log(infoParse);

    await t
    .expect(infoParse.username).contains('Google:cloudtester12345@gmail.com');

    });
});
Run Code Online (Sandbox Code Playgroud)

小智 5

尝试

test ('Control server info', async t => {

//test code
});
Run Code Online (Sandbox Code Playgroud)