Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server.on("connection", ...) returns the server instance instead of the client socket instance #72

Closed
brian-mann opened this issue Feb 24, 2016 · 3 comments

Comments

@brian-mann
Copy link

Per this library it doesn't seem possible to simulate socket.io clients emitting events.

I can only emit events from the server.

var Server = require("mock-server").Server
var mockServer = new Server("http://localhost:1111")

mockServer.on("connection", function(socket){
  // socket === mockServer
  // this makes no sense. socket should be the
  // client socket which connected, not the server.

  // in the real socket.io lib, socket is the client instance
})

In my code, I attach event listeners to the socket which connected, and I'm trying to simulate those. Is this possible using another method?

@thoov
Copy link
Owner

thoov commented Feb 29, 2016

@brian-mann Sorry for the delay in getting back to you on this and thanks for opening the issue. Could you attach the test that you are trying to write so I can use that as a test case?

@lgandecki
Copy link

This is still true, and for WebSocket as well. To be able to work with apollo subscriptions-transport-ws ( apollographql/subscriptions-transport-ws#374 ) I've created a hacky fork ( master...lgandecki:master ) for now, since it looks like you are rewriting this significantly I didn't think it was worth adding tests around it (although I haven't broken any).

Could you tell me a bit what's your plan here? Are you going to push with the rewrite? Or have you decided to stay with the current architecture?

@hervispichardo
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants