我正在用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:[email protected]');
});
});
尝试
test ('Control server info', async t => {
//test code
});