Zuul tests fail when using multiple sockets
Currently mocha tests using zuul have to use the same global socket -- if each test uses a separate socket, only the first test passes and every other test fails, regardless of the test.
It is probably related to multiplexing and the single socket being closed. It is also probably socket.io level because engine.io browser tests use individual sockets and work fine.
This fails:
it('should connect to localhost', function(done) {
var socket = io();
socket.emit('hi');
socket.on('hi', function(data){
socket.close();
done();
});
});
it('should connect to localhost again', function(done) {
var socket = io();
socket.emit('hi');
socket.on('hi', function(data){
socket.close();
done();
});
});
But this passes:
var socket = io();
it('should connect to localhost', function(done) {
socket.emit('hi');
socket.on('hi', function(data){
done();
});
});
it('should connect to localhost again', function(done) {
var socket = io();
socket.emit('hi');
socket.on('hi', function(data){
done();
});
});
@poohlty and I ran into this while writing tests.
The second time io() is called, the closed socket for '/' is returned. Inserting socket.open() before using it again almost works, but the original 'hi' handler is still bound, so it results in done() being called twice in the above example.
@guille: Was wondering if io()'s behavior could be to, if the socket exists but is not open, to reopen before returning it? Or is that too much of an exception?
@kevin-roark can this be closed?
This doesn't seem to be the case anymore.