Skip to content

Commit 8f615d4

Browse files
committed
First working socket.io test
1 parent a925362 commit 8f615d4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/server/_server_test.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,16 @@
142142

143143
describe("Socket.io Server", function() {
144144

145-
it("test connects to the server", function(done) {
145+
it("connects", function(done) {
146146
server.start(CONTENT_DIR, NOT_FOUND_PAGE, PORT, function() {
147147
var socket = io("http://localhost:" + PORT);
148-
socket.on('connect', function() {
149-
server.stop(done);
148+
socket.on("connect", function() {
149+
// timeout is necessary due to apparent race condition in socket.io-client
150+
// see https://github.com/socketio/socket.io-client/issues/935
151+
setTimeout(function() {
152+
socket.disconnect();
153+
server.stop(done);
154+
}, 50);
150155
});
151156
});
152157
});

0 commit comments

Comments
 (0)