I’m trying to test RTKQuery that an endpoint has been called using jest.
I eventually want to also be able to mock what the return data will be, but first I wanted to just check that the hook had been called.
An example below where I am trying to spy on myApi for the useGetMyListQuery hook which is autogenerated.
This throws and error when it runs, can anyone help?
it('Should render', async () => {
jest.spyOn(myApi, 'useGetMyListQuery')
render(
<Provider store={store}>
<MyComponent />
</Provider>
)
expect(myApi.useGetMyListQuery).toBeCalled()
})