-
-
Save ppcano/1292336 to your computer and use it in GitHub Desktop.
test: function( done ) { | |
var port = 8080, | |
io = require("socket.io").listen(port); | |
io.set('polling duration', .2); | |
var client = require("socket.io-client").connect( "http://localhost", { port: port }); | |
client.on('connect', function() { | |
client.disconnect(); | |
}); | |
client.on('disconnect', function() { | |
console.log(' client disconnect'); | |
client.socket.transport.websocket.finishClose(); | |
io.server.close(); | |
done(); | |
}); | |
}, |
HI, i've got similar code, but i could not get the same result as you. Could you give me advice about what i'm doing wrong?. The code is on https://gist.github.com/1325853. Running on expresso i've got the folloing result:
info - socket.io started
And it remains here, till i press control+C and I get the following:
^C
100% 1 tests
Thanks in advance.
i answered this question here: http://stackoverflow.com/questions/5965733/how-does-one-properly-shutdown-socket-io-websocket-client
Also, it could be that you are running your tests with the proper arguments:
-
run serial tests ( normally, the convention is to use 'done' instead of 'beforeExit' with is the term for no-serial tests ),
-
-t TIMEOUT, with a timeout big enough in order the tests won't fail because timing-out.
--> expresso mytest -s -t 10000
info - socket.io started
debug - client authorized
info - handshake authorized 15148061181922540821
debug - setting request GET /socket.io/1/websocket/15148061181922540821
debug - set heartbeat interval for client 15148061181922540821
debug - client authorized for
debug - websocket writing 1::
client disconnect
finish close ppcano
debug - websocket received data packet 0::
debug - got disconnection packet
info - transport end by forced client disconnection
debug - websocket writing 0::
info - transport end
debug - set close timeout for client 15148061181922540821
debug - cleared close timeout for client 15148061181922540821
debug - cleared heartbeat interval for client 15148061181922540821
debug - discarding transport