Lesson 36. Testing your application

 

Continual maintenance of your application in production requires fixing bugs. Fixing bugs means writing new code. Writing new code has the unforgiving tendency to break existing functionality. In this lesson, you take some steps to prevent the breaking of working code by implementing tests on your Node.js application. Writing tests in Node.js is similar to testing in other platforms and languages. First, you learn how to write simple tests for a function in your application. Then you implement tests for the controller actions and models to cover the bulk of your application’s code. By the end of this lesson, you’ll have the fundamental skills you need to get started testing your Node.js application.

This lesson covers

  • Using core modules to write assertion tests
  • Writing a Node.js test with mocha and chai
  • Building and running tests for controller actions with chai-http
  • Implementing tests for your API

36.1. Basic testing with core modules

36.2. Testing with mocha and chai

36.3. Testing with a database and server

Summary