stompjs icon indicating copy to clipboard operation
stompjs copied to clipboard

Options for Mock Stompjs Server

Open IgnacioHR opened this issue 4 years ago • 2 comments

Hello,

I'm missing a Mock Stomp Server that can be used to automate tests with jest. And documentation about how to write basic tests.

I've already tested https://github.com/rufusraghunath/js-stomp-utils/tree/master/packages/mock-stomp-broker with no success. The issue will be reported in that repository.

Thank you in advance!

IgnacioHR avatar Sep 06 '21 09:09 IgnacioHR

I know it makes a lot of sense to have a mock stomp broker.

For testing this library I needed one, at that time I could not find any reasonable one, so, ended up using a complete RabbitMQ server. To simulate errors (like missing heartbeats), I use a wrapper over the WebSocket which can alter (or eat away) responses. See the specs folder and the Doockerfile to check the current setup.

If one wants to use this code as a base, they can use quite a lot of classes, like Frame, Parser, etc. to implement a Mock broker. That would additionally allow mocks to run within even the browser (without using a TCP port). This will make tests run much faster.

If you would like to attempt and need details, please let me know.

kum-deepak avatar Sep 06 '21 12:09 kum-deepak

@IgnacioHR We are using https://github.com/rufusraghunath/js-stomp-utils/tree/master/packages/mock-stomp-broker in our e2e tests. It works fine to mock stomp responses.

sergiykh avatar Dec 21 '21 16:12 sergiykh