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. The second is the assertion library itself, the language we use to write our tests. Finally, we'll take a look at the idea of spies and stubs, which are fake representatives of certain parts of our code that are relied on when we need to track function calls to ensure an expected behavior.
Running tests with the Mocha framework
When writing tests for an application, you typically write them in batches that are module specific. These batches are referred to as suites or specs. Each suite typically contains a batch of tests organized in a way that almost mirrors the application itself. With Node, the idea is no different in that each suite of tests we write will be specific to an individual...