You can just kill the browser process. In this case, the browser will not be able to close the connection gracefully. It will look pretty much like a disconnected network connection to the server.
See this question at superuser.com on how to kill a process on MacOS.
An even more realistic test would be to create a virtual machine, start the client there (or server), and then terminate the virtual network connection.
Another option is to configure a local proxy server (note that several proxy servers already support WebSockets), connect to the server through this proxy server, and then simulate an interrupted connection by killing the proxy server. In this way, you could watch the servers and clients react to the event.
source share