thoov / mock-socket

Javascript mocking library for WebSockets and Socket.IO
MIT License
797 stars 118 forks source link

The onerror/onclose/... event handlers of websocket does not mock correctly #178

Open hktonylee opened 7 years ago

hktonylee commented 7 years ago

In a normal DOM object calling this.addEventListener('error', ...) does not affect this.onerror and vice versa. However in this mock library they affect each other and this certainly break the contract of using DOM EventTarget.

Please fix this because many libraries rely on this behaviour to work correctly. Please advice if I can submit a pull request about this breaking changes but make it more compatible with standard DOM web socket.

n1ru4l commented 6 years ago

For me those callbacks are not triggered when calling mockServer.stop().

Edit: They are triggered with mockServer.close(). 🎉