T
tRPC

❓-help

Testing with React Testing Library

Zzeph166511/28/2022
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!
UUUnknown User11/30/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!