@@ -48,7 +48,7 @@ describe('E2E WebSocket proxy', () => {
48
48
} ) ;
49
49
50
50
describe ( 'option.ws' , ( ) => {
51
- beforeEach ( async ( done ) => {
51
+ beforeEach ( async ( ) => {
52
52
proxyServer = createApp ( proxyMiddleware ) . listen ( SERVER_PORT ) ;
53
53
54
54
// quick & dirty Promise version of http.get (don't care about correctness)
@@ -59,8 +59,10 @@ describe('E2E WebSocket proxy', () => {
59
59
// do a second http request to make sure only 1 listener subscribes to upgrade request
60
60
await get ( `http://localhost:${ SERVER_PORT } /` ) ;
61
61
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
+ } ) ;
64
66
} ) ;
65
67
66
68
it ( 'should proxy to path' , ( done ) => {
@@ -81,7 +83,7 @@ describe('E2E WebSocket proxy', () => {
81
83
ws . on ( 'open' , done ) ;
82
84
} ) ;
83
85
84
- it ( 'should proxy to path' , async ( done ) => {
86
+ it ( 'should proxy to path' , ( done ) => {
85
87
ws . on ( 'message' , ( message ) => {
86
88
expect ( message ) . toBe ( 'foobar' ) ;
87
89
done ( ) ;
0 commit comments