Testing · Middle · Question 23 of 75
What does renderHook return?
const { result } = renderHook(() => useCounter());
act(() => result.current.increment());
expect(result.current.count).toBe(1);- ✓Correct answer: An object whose
result.currentholds the hook's latest return value - 2The hook's initial value only
- 3A mock of the hook
Explanation
Updates from outside React events must be wrapped in act. For hooks used by one component, testing that component is often better.