zeph1665
zeph16652y ago

Testing with React Testing Library

Hi! I am trying to test my
DestinationForm
DestinationForm
component using react testing library. My test is simply rendering the component:
test('contains 2 input fields and a submit button', () => {
const view = render(<DestinationForm />)
})
test('contains 2 input fields and a submit button', () => {
const view = render(<DestinationForm />)
})
But I get this error:
TypeError: Cannot destructure property 'client' of 'useContext(...)' as it is null.
const { mutateAsync, error, isLoading } = trpc.itinerary.create.useMutation()
TypeError: Cannot destructure property 'client' of 'useContext(...)' as it is null.
const { mutateAsync, error, isLoading } = trpc.itinerary.create.useMutation()
My guess is that I have to somehow wrap the DestinationForm component with some context so that it is aware of the query client but I'm not sure how to. I'm super new to testing so any help is appreciated(: Thank you!
1 Reply
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View