-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock RTK WebSockets #129
Comments
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! cc @kettanaito |
Second what @yannbf is saying here! We are bringing a first-class WebSocket support to MSW, which is already available in a public beta. npm i msw@next
I've got a few usage examples as well, feel free to reference those. |
MSW supports mocking WebSockets since Minimal usage example: import { ws } from 'msw'
const chat = ws.link('wss://api.example.com/chat')
export const YourStory = {
parameters: {
msw: {
handlers: [
chat.addEventListener('connection', ({ client }) => {
client.send('Hello from mock!')
})
]
}
}
} |
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: