加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 量角器和黄瓜:函数使用async / await超时

发布时间:2020-12-17 07:06:50 所属栏目:安全 来源:网络整理
导读:我正在使用Angular 5,Protractor和Cucumber进行e2e和bdd测试.当我运行终端ng e2e时,我收到以下错误: When I open the page # e2estepshome.steps.ts:15 Error: function timed out,ensure the promise resolves within 5000 milliseconds 在第15行,我有:
我正在使用Angular 5,Protractor和Cucumber进行e2e和bdd测试.当我运行终端ng e2e时,我收到以下错误:

When I open the page # e2estepshome.steps.ts:15

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

解决方法

答案很简单.默认情况下,Cucumber需要5000毫秒的异步挂钩,但我们可以通过这样做来配置它:

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读