I am trying to use Cucumber.JS to do my automated testing. If I do the following...
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
Everything works, however, if I do the following using And
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
I get
TypeError: Object # has no method 'And'
So what is the proper way to do this (Without saying you should be using when anyway because I have other scenarios that are not so simple)
I ended up being able to use And in the Gherkin and use this.When 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With