Test your Custom Hook Module with react-hooks-testing-library

Joe Previte
InstructorJoe Previte

Share this video with your friends

Send Tweet

It's always important to test your code, especially if you're open-sourcing it for others to use. In this video, we'll learn how to use react-hooks-testing-library to write a few tests for our custom hook.

Kanisorn
Kanisorn
~ 10 months ago

Can we still use @testing-library/react-hooks with react version 16.8. ?

Joe Previte
Joe Previteinstructor
~ 10 months ago

Not that I know of. According to the docs for @testing-library/react-hooks, they say,

The minimum supported version of react and react-test-renderer is ^16.9.0

Jeff
Jeff
~ 5 months ago

Isn't it safer to mock the network call? BTW, there's a funky typo in the transcript: "givs" should be "keys".

Joe Previte
Joe Previteinstructor
~ 5 months ago

@Jeff Yes, you're absolutely right that it's safer to mock the network call. Generally, that's preferred.

Thanks for the flag on the transcript! I've flagged the lesson for the egghead team to update.