Testing Custom Hooks with State

Learn to test custom React Hooks that contain state in this lesson.

Starter project

The project for this lesson contains a custom hook called useForm. This hook tracks the value of a field in a form and can handle the initial part of the form submission. It is a very simplified version of useForm from React Hook Form.

In this lesson, we’ll create tests on useForm.

A copy of the project is in the code widget below. Clicking the “Run” button executes the tests.

Get hands-on with 1200+ tech skills courses.