Protractor and Cucumber: function timed out using async/await

匿名 (未验证) 提交于 2019-12-03 01:39:01

问题:

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:

When I open the page # e2e\steps\home.steps.ts:15

Error: function timed out, ensure the promise resolves within 5000 milliseconds

In the line 15, I have:

 When(/^I open the page$/, async () => {     await browser.get('http://localhost:49156');  });

Specifically, it is the line:

 When(/^I open the page$/, async () => {

回答1:

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 () => {

It is even possible to configure it globally.

var {setDefaultTimeout} = require('cucumber'); setDefaultTimeout(60 * 1000);

More info: https://github.com/cucumber/cucumber-js/blob/master/docs/support_files/timeouts.md

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.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!