Setting Up Test Coverage

Understand the basics of test coverage and why it is important.

Introduction to test coverage

Test coverage is the quantifiable metric by which we determine how much of our code is actually being tested by our tests. Quality tests are wonderful but don't do us much good if we've left massive gaps of untested code in our application. Test coverage helps us ensure that these gaps are small or nonexistent, and it provides us the knowledge of where the gaps exist

Typically, we discuss test coverage in terms of a percentage of the total code, as well as a percentage of statements, branches, functions, and lines. Each of these has its own generated percentages that we can refer to. In this context, these terms have the following meanings:

  • Statements: This is a pure JavaScript statement, such as a variable declaration or assignment

Get hands-on with 1200+ tech skills courses.