You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking at this lib and could not find any clue on how you should mock your WebSocket when you are using a library like Redux and SocketIO. Let's say you have a RTK query like this:
endpoints: (build)=>({someSubscription: build.query<ResponseSchema[],void>({queryFn: async()=>{return{data: null}},asynconCacheEntryAdded(_,{ updateCachedData, cacheDataLoaded, cacheEntryRemoved }){constsocket=io('ws://localhost:3000/',{withCredentials: true,transports: ['websocket'],})socket.on("message",()=>{/* cache received msg in */})socket.close()},}),})
How can I mock the cached data? is it even possible to do it with this lib? if not with what I can do that?
The text was updated successfully, but these errors were encountered:
I think we need to leverage and utilise two things at the same time, the first one I think is this addon and the other one might be: https://github.com/thoov/mock-socket
After a few weeks I ended up asking same question and landing back to this page again but not luck still 😭
Hey there! MSW didn't support mocking web sockets before but it seems like it does now! If you're willing to make a contribution to this repo with a reasonable, simple websocket example, we can try to set mocks for it and it can serve as reference for others!
Hi dear reader
I was looking at this lib and could not find any clue on how you should mock your WebSocket when you are using a library like Redux and SocketIO. Let's say you have a RTK query like this:
How can I mock the cached data? is it even possible to do it with this lib? if not with what I can do that?
The text was updated successfully, but these errors were encountered: