October 2019
Intermediate to advanced
426 pages
11h 49m
English
We can also check the result before and after calling act and pass an initial value to our Hook.
Let's now test the initial value of our Hook:
test('should use initial value', () => { const { result } = renderHook(() => useCounter(123))
expect(result.current.count).toBe(123) act(() => result.current.increment()) expect(result.current.count).toBe(124)})
As we can see, we can simply pass the initial value to the Hook and check whether the value is the same.
Read now
Unlock full access