出于某些原因,我试图用 Promises 替换 TestCafe Async/Await。下面是我使用 promises 代替 await 的代码块。
但是出现如下错误:未等待对异步函数的调用。在操作、断言或它们的链之前使用“await”关键字 以确保它们以正确的顺序运行。
最佳答案
如果你不想使用async/await
,你可以从测试函数返回一个Promise:
fixture `Example`
.page `example.com`;
test(`example`, t => {
let promise = Promise.resolve(t);
return promise
.then(result => {
return result.typeText('...');
})
.then(result => {
return result.click('...');
});
});
关于javascript - 用 promises 替换 TestCafe async/await,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55952402/