BDD in CucumberJS

JavaScript automation testing has gained enormous popularity over the past few years. Many JavaScript developers create unit tests using tools like Protractor, BDD in CucumberJS and nightwatchjs and testers have also started writing automated regression suite using JavaScript to align with one automation testing approach which is followed by both QA (Acceptance tests) and Dev (Unit tests). In this post, we are going to see an example for CucumberJS with WebDriverJs which is helpful for newbies. As a testing service provider, sharing knowledge, exploring new testing tools and approaches are key differentiators of Codoid. Let’s begin the article with required tools section.
1) Required Tools
  • NodeJS
  • cucumber-js
  • WebDriverJs
  • Grunt
  • grunt-cucumberjs
  • chromedriver
  • chaijs
  • 2) Folder Structure
    cucumberjs-folder-structure
    3) Installation
  • Install Nodejs
  • Install grunt-cli globally
  • Create package.json
  • Install dependencies
  • 4) Create Feature
    Create ‘Codoid.feature’ file inside ‘features’ folder
    5) Create step definitions
    Create ‘my_steps.js’ inside ‘features/step definitions’ folder
    6) Create Gruntfile.js
    7) Execute
    Once the execution is completed, you can see ‘my_report.html’ inside reports folder as shown below. BDD in CucumberJS Source code of this example

    Leave a Reply

    Your email address will not be published. Required fields are marked *