O'Reilly logo

Web Development with MongoDB and NodeJS - Second Edition by Jason Krol, Bruno Joseph D'mello, Mithun Satheesh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Testing Your Code

Up until this point, we've been pretty much flying by the seat of our pants when it comes to the code we've been writing! We've literally had no way of knowing whether the code worked until we tested it out in an actual browser.

In this chapter, we will cover the following topics:

  • Running tests with the Mocha test framework
  • Writing tests with the Chai assertion library
  • Spies and stubs with Sinon and Proxyquire
  • Writing your first test
  • Testing our application

Tests are great for making sure your code functions properly, but they're also awesome for preventing new unexpected bugs from suddenly popping up because of an innocent little change you made to some unsuspecting code.

The tools of the trade

Let's start by taking a look ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required