Best practices when testing custom Phoenix.Socket.Transport implementations

In Jellyfish, we rely on custom Phoenix.Socket.Transport implementation and I wanted to ask about best practices in terms of how to properly test it.

In particular, is there any reason why Phoenix server is by default disabled in tests?
What comes to my mind is to run the whole server and use some third party library to create a real WebScoket.

Another solution, which we currently use, is to manually invoke callbacks. It works pretty well but creating a real WebSocket would test more things, I think.

It is because most applications don’t need the server running in tests by default, but you can always enable it.

Yup, this is what we do to run integration tests in Phoenix itself.

1 Like

Would it make sense to make WebsocketClient public? It looks pretty generic :thinking:

Not really. I dont think it is general purpose and I don’t think it should be the job of Phoenix to expose a websocket client.

1 Like