我正在 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)