Testing Custom Hooks

Hooks are a great way to abstract and reuse functionality between React components.

Testing them is very straightforward too with some helper functions from React Testing Library.

In this lesson we will write and test a useCounter hook, which lets you increment/decrement/reset a counter.

Loading full lesson content & code...

Ready to try running tests for this lesson?