Testing JavaScript Applications cover
welcome to this free extract from
an online version of the Manning book.
to read more
or

2 What to test and when?

 

This chapter covers

  • The different types of tests and when to use them
  • Writing your first automated tests
  • How to balance coupling, maintenance, and cost

In the previous chapter, to facilitate explaining what tests are and their benefits, I put all the different types of tests in a single, big conceptual box. I showed tests that dealt with databases, tests that directly called one function, and tests that called multiple functions. In this chapter, I’ll take tests out of that box and put them into separate shelves, each one containing tests of a different kind.

It’s essential to understand how tests fit into different categories because different types of tests serve different purposes. When building a car, for example, it’s crucial to test the engine and the ignition system individually, but it’s also vital to ensure they work together. If not, both the engine and the ignition system are useless. It’s equally as important to test whether people can drive the car once all parts are in place, or else nobody will go anywhere.

When we build software, we want to have similar guarantees. We want to ensure our functions work in isolation as well as in integration. And, when we put all of these functions together in an application, we want to ensure customers can use it.

2.1 The testing pyramid

2.2 Unit tests

2.3 Integration tests

2.4 End-to-end tests

2.4.1 Testing HTTP APIs

2.4.2 Testing GUIs

2.4.3 Acceptance tests and end-to-end tests are not the same

2.5 Exploratory testing and the value of QA

2.6 Tests, cost, and revenue

Summary

sitemap