【问题标题】:protractor 3.0.0 and cucumber automated testingprotractor 3.0.0 和 cucumber 自动化测试
【发布时间】:2016-01-15 21:27:29
【问题描述】:

我目前正在使用量角器、黄瓜和 chai/chai-as-promised 进行自动化测试。我当前的代码使用量角器 1.8.0,我想将其更新到最新版本。问题是最新版本的量角器不支持黄瓜。

要使用 cucumber 作为您的框架,protractor (http://angular.github.io/protractor/#/frameworks) 指出您使用 protractor-cucumber-framework (https://github.com/mattfritz/protractor-cucumber-framework)。我已经尝试将它与我当前的代码和一些较小的示例项目集成,但没有让它们工作。我得到的主要错误是:

错误:在 Timer.listOnTimeout 5000 毫秒后步骤超时 (timers.js:92:15)

我已尝试按照黄瓜的建议全局更改默认超时::// features/support/env.js

var configure = function () {
  this.setDefaultTimeout(60 * 1000);
};

module.exports = configure;

但我的设置似乎遗漏了一些东西。

那么,有谁知道一个可以向我展示新量角器/黄瓜框架的正确设置的好例子吗?如果没有,有谁知道一个示例,说明如何全局更改默认超时?

【问题讨论】:

标签: javascript angularjs cucumber automated-tests protractor


【解决方案1】:

你应该添加

this.setDefaultTimeout(60000);

到您的step_def 文件之一。例如:

module.exports = function () {

    this.setDefaultTimeout(60000);
    this.After(function (callback) { ... } 

}

或者你应该添加 //features/support/env.js 到

cucumberOpts:{require: ['//features/support/env.js']}

与您的 stepDefinition 文件一起排列

【讨论】:

【解决方案2】:

感谢@Ivan, 与cucumber-protractor-framework 和typescript:

在 protractor.conf.js 中

cucumberOpts: {
    compiler: "ts:ts-node/register",
    require: [
      './src/env.ts', //<- added
      './src/**/*.steps.ts'
    ]
  },

在 src/env.ts 中:

import {setDefaultTimeout} from 'cucumber';

setDefaultTimeout(9001);

【讨论】:

    猜你喜欢
    • 2014-06-15
    • 2022-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-22
    • 1970-01-01
    相关资源
    最近更新 更多