Testing · Senior · Question 39 of 75
When is it better to test a custom hook via renderHook rather than through a component?
- ✓Correct answer: For reusable hooks with a public API (libraries, shared utilities), where the hook itself is the product
- 2Always - components should never be used for hook tests
- 3Only for hooks without state
Explanation
For a hook used by one component, testing that component's behaviour gives more confidence with less coupling.