Book Image

Learning Behavior-driven development with Javascript

Book Image

Learning Behavior-driven development with Javascript

Overview of this book

Table of Contents (17 chapters)
Learning Behavior-driven Development with JavaScript
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Summary


In this chapter, you learned how to use Gherkin and Cucumber.js to write BDD features. This has been a long and hard chapter, because you not only needed to learn a new tool, Cucumber.js, but you also needed to build a set of utilities to make your life easier.

Always write features and scenarios in a language that makes sense and is understandable to the stakeholders. Avoid technical details, such as database structure, identifiers, or low-level operations, in your Gherkin.

It is a best practice to create a custom world object. The world object will be instantiated once before each scenario, so it is a good place to store any information that needs to be accessed by all the steps in the same scenario. In general, keep the code in the step handlers as small as possible. To achieve this, try to move some logic to the world object.

Create small utilities to allow Cucumber.js to deal with promises, synchronous steps, and Chai assertions more easily.

In Gherkin, you can create data tables...