Replies: 1 comment 1 reply
-
That seems about right since Your code here const handleSomething = (): Promise<OfTypeMyObject> => {
return myQuery({ myParam: 123 }).unwrap().then((response: OfTypeMyObject) => {dispatch(setMyData(response))});
} ends with a method body that doesn't return anything - so it returns |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I am not able to properly test a state dispatch using jest, rtk, rtkq and msw. After successfully mocking the API call + mocking a response (Promise.resolve(myObject)) with MSW I would like to update the state, which ends up in a pending premise or an undefined resolve respectively. The business logic of my hook is the following:
useMyCustomHook
According to the example here in this repo, I build a
RenderWrapper
which setup the store and passes the children. In my jest test I am rendering my above mentioned custom hook, which also follows mostly your example.test
which ends up with an expected
myObject
and a receivedundefined
. I logged the steps and until I want to update the state everything is working fine.Does anyone have an idea, what's the issue here? It seems like the rendered store isn't updated correctly. May someone link a working example? If more information is required, let me know.
Thanks everyone
Beta Was this translation helpful? Give feedback.
All reactions