xk6-websockets icon indicating copy to clipboard operation
xk6-websockets copied to clipboard

socket io wrapper with promises

Open andrew-delph opened this issue 2 years ago • 6 comments

https://gist.github.com/andrew-delph/05a45f7f4293a85755df5fbd15ad26c1

andrew-delph avatar Feb 24 '23 00:02 andrew-delph

This makes testing so much easier for socket io!

andrew-delph avatar Feb 24 '23 17:02 andrew-delph

Hey @andrew-delph , thanks for building and sharing the socket.io library/wrapper.

This is definitely something that would be useful for others folks in the community:

  • https://community.k6.io/t/k6-socket-loadtest/1730
  • https://community.k6.io/t/how-to-capture-the-server-data-in-k6-scripts/1632/3
  • https://github.com/grafana/k6/issues/667
  • https://github.com/grafana/k6/issues/1306

I will eventually make an example of this with the babel configs so its easy to setup.

Not all k6 users use Typescript, so it would be ideal if the bundler could generate a JS build for non-typescript users.

ppcano avatar Mar 20 '23 09:03 ppcano

A JS version gist in case anyone would need it https://gist.github.com/laub1199/2e045c4715ef8c859be9d116353861e2

sennett-lau avatar Apr 12 '23 03:04 sennett-lau

@sennett-lau the gist doesn't work, do you mind sharing it again? ❤️

vvargas90 avatar Nov 27 '23 12:11 vvargas90

@sennett-lau the gist doesn't work, do you mind sharing it again? ❤️

Here you go! I changed the username aha :D

https://gist.github.com/sennett-lau/2e045c4715ef8c859be9d116353861e2

sennett-lau avatar Nov 27 '23 13:11 sennett-lau

I tried the JS version from @sennett-lau but it is not working. I get this error:

ERRO[0001] TypeError: Value is not an object: undefined
        at connect (file:///home/tms/workspace/socketio/libs/K6SocketIoExp.js:7:22(8))
        at file:///home/tms/workspace/socketio/src/main.js:34:1(20)  executor=per-vu-iterations scenario=default source=stacktrace

Is anyone able to get it working?

Thank you.

andreav avatar Jul 19 '24 17:07 andreav