【问题标题】:Getting undefined step definition warning in Cucumber Protractor setup在 Cucumber Protractor 设置中获取未定义的步骤定义警告
【发布时间】:2017-06-02 13:30:25
【问题描述】:

我已经在本地安装了 npm 模块(在下面的 package.json 中找到依赖项详细信息)并尝试执行下面的黄瓜功能文件和 SD,但得到 未定义。实施.. 消息。

我已经准备好我的功能文件如下:存储在:test/features/sample.feature

 Feature: Running Cucumber with Protractor
 @test
 Scenario: To verify the Search result
  Given I am on home page

并实现SD如下:存储在:test/step_definitions/sample.steps.js

 module.exports = function() {
  this.Given(/^I am on home page$/, function () {
    return browser.get("http://www.google.com");
   });
 }

我在 conf.js 中的 specs & cucumberOpts 如下:

 specs: [
 './../features/*.feature'
 ],

 cucumberOpts: {
  require: ['./step_definitions/*.steps.js'],
  tags: '@test',
  strict: true,
  format: 'pretty'
 }

已安装的 package.json 依赖详情:

 "dependencies": {
  "chai": "^4.0.1",
  "chai-as-promised": "^6.0.0",
  "cucumber": "^2.3.0",
  "protractor": "^5.1.2",
  "protractor-cucumber-framework": "^3.1.1"
 }

但在执行中获取消息为:

 1 scenario (1 undefined)
 1 step (1 undefined)
 0m00.000s

谁能帮我出来...

【问题讨论】:

    标签: npm protractor cucumber bdd cucumberjs


    【解决方案1】:

    您的问题似乎与步骤定义本身有关。

    您似乎在为 2.x 框架使用旧的 CucumberJS 1.x 语法。

    以下是使用 2.x 语法提供的步骤定义的更新:

    var {defineSupportCode} = require('cucumber');
    
    defineSupportCode(({Given, When, Then}) => {
    
      Given(/^I am on home page$/, function () {
        return browser.get("http://www.google.com");
      });
    
    });
    

    【讨论】:

      猜你喜欢
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 1970-01-01
      • 2021-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多