I appreciate the very high praise! Sorry for the late response. I assumed that this article was in the forgotten chasms. xD I guess it's gotten more attention recently somehow.
I'll have to get back to you on this. But at a first glance -- from the example you shared -- it seems like there's still a custom server being used. So my first thought would be to update the `startServer` utility function accordingly (and to update whatever else is necessary to make that an easy process).
Some potential ideas:
1) Simply instantiate the web socket server from another file and export it. Then in the `startServer` utility (and in your production code), you can setup all the listeners directly.
2) Change the `createWebSocketServer` utility to accept no arguments. Instead, it will instantiate a `WebSocketServer`, create any necessary `onConnection` listeners, and then return the instance of `WebSocketServer` itself.
If you run with the 2nd idea, then in the `startServer` utility function for tests, you can probably still create a custom `http` server. But instead of using `createWebSocketServer` as the article shows, you would just use it to get access to the instance of a `WebSocketServer`. Then you could add a custom `onUpgrade` listener to support your testing needs. (Remember to add the `onUpgrade` listener before calling `server.listen`.)
Let me know if this helps or if you have additional questions. (If I have new findings before you respond, I'll share them.)