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

Chapter 3. Writing BDD Features

Although in the last chapter, you learned how to use Mocha, Sinon, and Chai to code some BDD tests, it was not so clear how we can write a good feature, given a set of requirements. In this chapter, we will go through the following topics:

  • Exploring in greater depth how to write good features. For this, we will work on a more realistic example: myCafé, an imaginary start-up.

  • Since myCafé is a JavaScript server, we will need to implement its functionality using asynchronous programming, so we will learn how to test asynchronous code.

  • We will explore more techniques to organize your test codebase so that we can make it more expressive and reuse code across different features.

What we are not going to see in this chapter is the actual implementation of the system, but only the code of the tests. I expect you to write the actual code necessary to make the tests pass! This way, you will be able to practice the test-first cycle a bit more.