Open JJ opened 1 year ago
See https://github.com/thoov/mock-socket#stubbing-the-global
window.WebSocket
is stubbed out once new Server
is called
See https://github.com/thoov/mock-socket#stubbing-the-global
window.WebSocket
is stubbed out oncenew Server
is called
Right, but if you use this on the server-side, it does not look like it does.
This library is intended for testing the client, so the WebSocket connecting to the mocked Server instead of the real one.
Server-side tests require another types of tests according to the server library implementation, so anyway you need to stub the protocol on the server.
If you want to use it on the server anyway, you need to import both WebSocket
and Server
from the library and write tests from the server perspective
That's exactly my point. Maybe a clarification in the example would help? After all, this example is simply under "Usage", no mention of the specific environment. I can craft a PR if that would help.
In this code
https://github.com/thoov/mock-socket/blob/47eab99d42b4f17abe8b7cc6ab1466cca6768750/README.md?plain=1#L39-L44
is
WebSocket
a regular one, or should it be imported from the library so that it can be mocked. In other word, is the URL mocked or the URL and the websocket?