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

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
~ 4 years ago

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

Joe Previteinstructor
~ 4 years 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
~ 4 years ago

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

Joe Previteinstructor
~ 4 years 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.