It’s great that our form can be submitted, but we need to get that data to our server to actually save the post to the database. We don’t want to actually make requests to the server during these unit tests, so we’ll mock out the function responsible for doing that and assert that it’s being called with the right data. Then we’ll go ahead and implement that functionality in our form component.


Test Drive the API Call of a React Form with React Testing Library