Closed
Description
Honestly, it got me confused big time. Considering that most of the tests might actually want to validate the output of the custom hook I find it strange we need to do this.
test('accepts a default initial value for `count`', () => {
let count
testHook(() => ({count} = useCounter({})))
expect(count).toBe(0)
})
So I would like to propose getting the output directly.
test('accepts a default initial value for `count`', () => {
const { result } = testHook(() => useCounter({}))
expect(result.count).toBe(0)
})
It can be compared to a render
where we are getting container
(and bunch of getters) to write our expectations. The testHook
is kinda inconsistent in this.