mercredi 9 septembre 2015

How can I test a socket.io server with multiple clients?

I'm trying to write tests for a socket.io server.

io.on('connection', function (socket) {
  socket.on('say', function (msg) {
    socket.broadcast.emit('update', msg);
  });
});

Each client receives all messages sent by the others​. I just want to test that.

To do this, my test needs to simulate multiple clients. But ​socket.io-client​ reuses connections, which makes that hard.

How should I test this code?

Aucun commentaire:

Enregistrer un commentaire