From 4193d3bd74e5ec02341707587b9832650d49a004 Mon Sep 17 00:00:00 2001 From: Damian Kaczmarek Date: Tue, 10 Jun 2014 01:49:16 +0200 Subject: [PATCH] Fix #657 --- test/lib-http-proxy-test.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/lib-http-proxy-test.js b/test/lib-http-proxy-test.js index d6d5b31..220d2f7 100644 --- a/test/lib-http-proxy-test.js +++ b/test/lib-http-proxy-test.js @@ -294,9 +294,11 @@ describe('lib/http-proxy.js', function() { var proxy = httpProxy.createProxyServer({ target: 'ws://127.0.0.1:' + ports.source, ws: true - }), - proxyServer = proxy.listen(ports.proxy), - destiny = io.listen(ports.source, function () { + }); + proxyServer = proxy.listen(ports.proxy); + var server = http.createServer(); + destiny = io.listen(server); + function startSocketIo() { var client = ioClient.connect('ws://127.0.0.1:' + ports.proxy); client.on('connect', function () { @@ -306,10 +308,12 @@ describe('lib/http-proxy.js', function() { client.on('outgoing', function (data) { expect(data).to.be('Hello over websockets'); proxyServer._server.close(); - destiny.server.close(); + server.close(); done(); }); - }); + } + server.listen(ports.source); + server.on('listening', startSocketIo); destiny.sockets.on('connection', function (socket) { socket.on('incoming', function (msg) {