3 Testing techniques

This chapter covers

  • Organizing your tests comprehensively
  • Writing assertions that are flexible and robust
  • Isolating and instrumenting parts of your code for tests
  • Defining strategies for choosing what to test and what not to
  • Learning what code coverage is and how to measure it

Well-written tests have two main qualities: they break only when the application misbehaves, and they tell you precisely what’s wrong. In this chapter, we will focus on techniques that help you achieve these two goals.

If you’ve written a test for the addToCart function, for example, you don’t want it to break if that function is still working. If the test does break, it will generate extra costs because you will have to spend time updating it. ...

Get Testing JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.