2014-07-14 5 views
3

Cucumber.JS를 사용하여 자동화 된 테스트를 수행하려고합니다. 다음과 같은 처리를 할 경우 ...작은 오이에서 cucumber.js를 사용하여 "And"를 사용하는 방법

var sharedSteps = module.exports = function(){ 
    this.World = require("../support/world.js").World; 
    this.When(/^I click on the cart$/, function(next) { 
     this.client.click("#cartLink", function(err, res){ 
     }); 
    }); 
    ... 
} 

Scenario: Make sure clicking on the cart works 
    Given I go on the website "https://site.com/" 
    When I click on the cart 
    Then I should be on the cart page 

모든 것은 내가 할 경우 다음 그리고

var sharedSteps = module.exports = function(){ 
    this.World = require("../support/world.js").World; 
    this.And(/^I click on the cart$/, function(next) { 
     this.client.click("#cartLink", function(err, res){ 
     }); 
    }); 
    ... 
} 

Scenario: Make sure clicking on the cart works 
    Given I go on the website "https://site.com/" 
    And I click on the cart 
    Then I should be on the cart page 

내가

TypeError: Object # has no method 'And'

를 얻을 수를 그래서 적절한 무엇 사용하지만, 작동 (너무 간단하지 않은 다른 시나리오를 사용하기 때문에 어쨌든 사용해야 할 것이라고 말하지 않고)

답변

2

나는 Gherkin에서 And를 사용할 수있게되었고 결국은 this.When

+3

'And'는 시나리오에서만 사용되며 단계 정의 방법으로는 사용되지 않습니다. 의미 적으로 "이전 단계와 동일한 키워드"를 의미합니다. 기술적으로 이것은 단지 또 다른 단계입니다. 사실, 단계 정의에서'Given()','When()'와'Then() '을 같은 의미로 사용할 수 있습니다. Cucumber는 step 키워드와 단계 정의 함수를 일치시키지 않습니다. – jbpros