量角器和黄瓜:使用异步/等待功能超时 [英] Protractor and Cucumber: function timed out using async/await
问题描述
我正在使用Angular 5,Protractor和Cucumber进行e2e和bdd测试.在终端ng e2e
上运行时,出现以下错误:
I'm doing e2e and bdd tests using Angular 5, Protractor and Cucumber. When I run on terminal ng e2e
I get the following error:
当我打开页面#e2e \ steps \ home.steps.ts:15
When I open the page # e2e\steps\home.steps.ts:15
错误:函数超时,确保承诺在5000范围内分解 毫秒
Error: function timed out, ensure the promise resolves within 5000 milliseconds
在第15行中,我有:
When(/^I open the page$/, async () => {
await browser.get('http://localhost:49156');
});
具体来说,这是一行:
When(/^I open the page$/, async () => {
推荐答案
Te答案非常简单.默认情况下,Cucumber花费5000ms进行异步挂钩,但是我们可以通过执行以下操作对其进行配置:
Te answer is very simple. By default, Cucumber takes 5000ms for asynchronous hooks, but we can configure it by doing this:
When(/^I open the page$/, {timeout: 2 * 5000}, async () => {
甚至可以全局配置它.
var {setDefaultTimeout} = require('cucumber');
setDefaultTimeout(60 * 1000);
更多信息: https://github.com/cucumber/cucumber-js/blob/master/docs/support_files/timeouts.md
另一件事,我对端口进行了严重配置,如您所见,我在端口49156上配置了该端口,因为我已经知道它是默认端口,但似乎已经更改,现在是端口49152.
Another thing, I configured the port badly, as you can see, I configured it on port 49156 because I had read that it was the default port, but it seems that has already changed and is now port 49152.
这篇关于量角器和黄瓜:使用异步/等待功能超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!