In the previous chapter, you learned that the create-react-app
tool was created to make developing React applications easier. It does so by eliminating upfront configuration—you go straight to building components. Jest was created with the same purpose in mind, eliminating the upfront boilerplate that you would typically have to create just to start writing tests. In addition to removing the initial unit test configuration factor, Jest has some other tricks up its sleeve. Let's go over some of the driving principles of testing with Jest.
The last thing you want to spend time on is testing someone else's code. Yet, sometimes you're forced to do exactly that. For example, let's say that you want to test a function that makes a fetch()
call to some HTTP API. Another example: your React component uses some library to help set and manipulate its state.
In both of these examples, there's code that you didn't implement that...