@@ -48,7 +48,7 @@ describe('E2E WebSocket proxy', () => {
4848 } ) ;
4949
5050 describe ( 'option.ws' , ( ) => {
51- beforeEach ( async ( done ) => {
51+ beforeEach ( async ( ) => {
5252 proxyServer = createApp ( proxyMiddleware ) . listen ( SERVER_PORT ) ;
5353
5454 // quick & dirty Promise version of http.get (don't care about correctness)
@@ -59,8 +59,10 @@ describe('E2E WebSocket proxy', () => {
5959 // do a second http request to make sure only 1 listener subscribes to upgrade request
6060 await get ( `http://localhost:${ SERVER_PORT } /` ) ;
6161
62- ws = new WebSocket ( `ws://localhost:${ SERVER_PORT } /socket` ) ;
63- ws . on ( 'open' , done ) ;
62+ return new Promise ( ( resolve ) => {
63+ ws = new WebSocket ( `ws://localhost:${ SERVER_PORT } /socket` ) ;
64+ ws . on ( 'open' , resolve ) ;
65+ } ) ;
6466 } ) ;
6567
6668 it ( 'should proxy to path' , ( done ) => {
@@ -81,7 +83,7 @@ describe('E2E WebSocket proxy', () => {
8183 ws . on ( 'open' , done ) ;
8284 } ) ;
8385
84- it ( 'should proxy to path' , async ( done ) => {
86+ it ( 'should proxy to path' , ( done ) => {
8587 ws . on ( 'message' , ( message ) => {
8688 expect ( message ) . toBe ( 'foobar' ) ;
8789 done ( ) ;
0 commit comments