Book Image

Web Development with MongoDB and NodeJS Second edition

Book Image

Web Development with MongoDB and NodeJS Second edition

Overview of this book

Table of Contents (19 chapters)
Web Development with MongoDB and NodeJS Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
12
Popular Node.js Web Frameworks
Index

The tools of the trade


Let's start by taking a look at the various tools and libraries we're going to be using to run and write our tests. There are three main concepts we need to cover before we can actually start writing real tests.

The first is a test runner or the framework we use to run our suite of tests.

Most of the frameworks follow Test Driven Development (TDD) and its process relies on the following steps:

  1. It defines a unit test

  2. Implements the unit

  3. Executes the test and verifies that the test passes

The second concept is the assertion library itself—the language we use to write our tests. A special version of using assertion language, to design and build pieces of functionality incrementally guided by an expected behavior is Behavior Driven Development (BDD).

For both TDD and BDD, we can use the Mocha testing framework; however, we will be writing assertions using a special assertion library called Chai.js

Finally, we'll take a look at the idea of spies and stubs, which are fake representatives...