What's a good level of code coverage?
Let me start by saying: Don't let coverage stop you from writing tests. You might be thinking "Oh, but I'll never reach 100% code coverage, what's the point?", but realistically, any tests are better than no tests.
For the apps we build day to day, 100% code coverage is often unrealistic, and suffers from diminishing returns (as in, you'll get less benefit per test written once you pass a certain percentage of code covered). As well as this, it's possible to reach "100% code coverage" without knowing your React components can render properly in all cases (particularly when using Enzyme and
Don't use code coverage as an arbitrary milestone. Instead, write high quality tests for your most valuable features and components.
Think about it this way, if you were a user for the web app you build, what functionality do you use every day, and would get upset if it stopped working? That's the functionality you need to have covered by tests.
If you then hit 100% code coverage as a result of testing all of your app's functionality - great! But don't let the number be your focus.
Let's talk about test-driven development (TDD) in Chapter 7: Should you use test-driven development (TDD)?