2017-06-02 39 views
0

我已經在本地安裝了npm模塊(在下面的package.json中找到依賴關係的詳細信息),並嘗試執行下面的cucumber功能文件和SD,但是獲取未定義。執行..消息。在Cucumber量角器設置中獲取未定義的步驟定義警告

我已準備了我的特徵文件,如下:在存儲:測試/功能/ sample.feature

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

並實現瞭如下的SD:儲存在:測試/ step_definitions/sample.steps .js文件

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

而且我規格& cucumberOpts在如下conf.js:

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

你的問題似乎是與步驟定義本身。

您似乎對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"); 
    }); 

}); 
相關問題