ZephZ
tRPC4y ago
1 reply
Zeph

Testing with React Testing Library

Hi! I am trying to test my
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 />)
})

But I get this error:
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!
Was this page helpful?