React Hooks Testing Library
Examine the usage for the React Hooks Testing Library and when it should be used.
We'll cover the following...
The benefits and an example
react-hooks-testing-library
is an open-source npm package that tests React Hooks.
The Testing Library makes it easier to interact with a hook during unit testing. Some benefits are mentioned below:
-
Renders the hook using
renderHook
helper and provides theresult
-
Allows you to access properties from hook output by using
result.current
. This reference is set to the output of the currently rendered hook. -
Provides
act
helper which can be used to trigger functions returned ...