如何解决protractor.config.js中的promise

时间:2017-09-13 09:50:55

标签: typescript protractor angular-cli

我在我的配置中添加了protractor-angular-screenshot-reporter能够生成报告,但在控制台中我收到错误“Unhanded promise rejection

1 个答案:

答案 0 :(得分:1)

如果你有这样的代码

,就会给你这个错误
.then(() => console.log('Success')); // second parameter is for rejection function

这里我错过了reject函数作为第二个参数传递给then。所以你还需要传递它来传递编译器。您需要有一个代码部分,您可以在其中处理来自代码异步部分的错误。

.then(() => console.log('Success'), (err) => console.log(err));

对于代码中的每个Promise,您还需要传递一个逻辑,以便在应用程序的错误情况下运行。