Chapter 10. Testing Node applications

 

This chapter covers

  • Testing logic with Node’s assert module
  • Using Node unit-testing frameworks
  • Simulating and controlling web browsers using Node

As you add features to your application, you run the risk of introducing bugs. An application isn’t complete if it’s not tested, and as manual testing is tedious and prone to human error, automated testing has become increasingly popular with developers. Automated testing involves writing logic to test your code, rather than running through application functionality by hand.

If the idea of automated testing is new to you, think of it as a robot doing all of the boring stuff for you, allowing you to focus on the interesting stuff. Every time you make a change to the code, you can get the robot to make sure bugs haven’t crept in. Although you may not have completed or started your first Node application yet, it’s good to get a handle on how you can implement automated testing because you’ll be able to write tests as you develop.

10.1. Unit testing

10.2. Acceptance testing

10.3. Summary