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 2. Automating Tests with Mocha, Chai, and Sinon

Before we start making some BDD, let's familiarize ourselves with the basic tools available in JavaScript to write and execute a test. In this chapter, we will explore the main capabilities of Mocha, the most popular test runner in JavaScript. We will perform the following tasks:

  • Writing expressive assertions using the Chai package

  • Creating test doubles using the Sinon and sinon-chai packages

  • Exploring the basic techniques for organizing our test codebase

To achieve these goals, we will perform a small code kata, or coding exercise, where we will be able to practice not only the tools, but also the test-first cycle explained in the previous chapter.