adonis-websocket
adonis-websocket copied to clipboard
Automated websocket testing
Hey there, we've started adding websockets into our project a few days ago and I really enjoy using it. The API turned out to be great and being able to have middleware is amazing.
Our websocket use case is mostly very unidirectional from Server to Client. Let me give you an example:
- User A sends a
RESTful requestto theServer Serverpersists some things into the database and performs other actions.Serverthen needs to notify Users B, C that something has changed.
As of now, all my REST api tests are api endpoint tests using trait('Test/ApiClient') and the testing experience + code confidence are incomparable to any other tests I write.
Ideally, I would like to also have a SocketClient trait so that I can register a fake socket Client to a channel, send some HTTP requests and then assert the messages received by my mocked socket Client.
Is there a better way of testing this and how would I go about mocking the Socket Client (which typically runs in the Browser) in node?
The testing section for sockets is also missing from the docs for which I'll happily send a PR.