Exercise: Mocking
Explore how to implement tests that mock the fetch function in React. This lesson guides you through verifying success and error messages upon form submission by completing tests in Jest and React Testing Library. Gain hands-on experience with mocking fetch to improve test reliability.
We'll cover the following...
We'll cover the following...
Starter project
The starter project contains a form that allows a user to enter a person’s name and score. The project includes two tests that verify the following:
- When the form is successfully submitted, a success message is rendered.
- When the form is unsuccessfully submitted, an error message is rendered.
The tests haven’t been implemented yet. In this exercise, you’ll fully implement these tests.
The skeleton code is given below: ...