@@ -294,9 +294,11 @@ describe('lib/http-proxy.js', function() {
294
294
var proxy = httpProxy . createProxyServer ( {
295
295
target : 'ws://127.0.0.1:' + ports . source ,
296
296
ws : true
297
- } ) ,
298
- proxyServer = proxy . listen ( ports . proxy ) ,
299
- destiny = io . listen ( ports . source , function ( ) {
297
+ } ) ;
298
+ proxyServer = proxy . listen ( ports . proxy ) ;
299
+ var server = http . createServer ( ) ;
300
+ destiny = io . listen ( server ) ;
301
+ function startSocketIo ( ) {
300
302
var client = ioClient . connect ( 'ws://127.0.0.1:' + ports . proxy ) ;
301
303
302
304
client . on ( 'connect' , function ( ) {
@@ -306,10 +308,12 @@ describe('lib/http-proxy.js', function() {
306
308
client . on ( 'outgoing' , function ( data ) {
307
309
expect ( data ) . to . be ( 'Hello over websockets' ) ;
308
310
proxyServer . _server . close ( ) ;
309
- destiny . server . close ( ) ;
311
+ server . close ( ) ;
310
312
done ( ) ;
311
313
} ) ;
312
- } ) ;
314
+ }
315
+ server . listen ( ports . source ) ;
316
+ server . on ( 'listening' , startSocketIo ) ;
313
317
314
318
destiny . sockets . on ( 'connection' , function ( socket ) {
315
319
socket . on ( 'incoming' , function ( msg ) {
0 commit comments