Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Npm 在量角器设置中获取未定义的步骤定义警告_Npm_Protractor_Cucumber_Bdd_Cucumberjs - Fatal编程技术网

Npm 在量角器设置中获取未定义的步骤定义警告

Npm 在量角器设置中获取未定义的步骤定义警告,npm,protractor,cucumber,bdd,cucumberjs,Npm,Protractor,Cucumber,Bdd,Cucumberjs,我已经在本地安装了npm模块(在下面的package.json中找到依赖项的详细信息),并尝试执行下面的cucumber特性文件和SD,但未定义。执行..消息 我已按如下方式准备了功能文件:存储在:test/features/sample.feature Feature: Running Cucumber with Protractor @test Scenario: To verify the Search result Given I am on home page 并实现了SD

我已经在本地安装了npm模块(在下面的package.json中找到依赖项的详细信息),并尝试执行下面的cucumber特性文件和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中的my规格和黄瓜选项,如下所示:

 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

谁能帮我说出来…

你的问题似乎在于步骤定义本身

对于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");
  });

});