diff --git a/package.json b/package.json index bbf2e8b2..189df85c 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,7 @@ "supertest": "^6.1.5", "ts-jest": "^27.0.4", "typescript": "^4.3.5", - "ws": "^7.4.6" + "ws": "^8.1.0" }, "dependencies": { "@types/http-proxy": "^1.17.5", diff --git a/test/e2e/websocket.spec.ts b/test/e2e/websocket.spec.ts index d2e674ee..bb80b166 100644 --- a/test/e2e/websocket.spec.ts +++ b/test/e2e/websocket.spec.ts @@ -25,7 +25,8 @@ describe('E2E WebSocket proxy', () => { wss = new WebSocketServer({ port: WS_SERVER_PORT }); wss.on('connection', (websocket) => { - websocket.on('message', (message) => { + websocket.on('message', (data, isBinary) => { + const message = isBinary ? data : data.toString(); websocket.send(message); // echo received message }); }); @@ -66,7 +67,8 @@ describe('E2E WebSocket proxy', () => { }); it('should proxy to path', (done) => { - ws.on('message', (message) => { + ws.on('message', (data, isBinary) => { + const message = isBinary ? data : data.toString(); expect(message).toBe('foobar'); done(); }); @@ -84,7 +86,8 @@ describe('E2E WebSocket proxy', () => { }); it('should proxy to path', (done) => { - ws.on('message', (message) => { + ws.on('message', (data, isBinary) => { + const message = isBinary ? data : data.toString(); expect(message).toBe('foobar'); done(); }); @@ -109,7 +112,8 @@ describe('E2E WebSocket proxy', () => { }); it('should proxy to path', (done) => { - ws.on('message', (message) => { + ws.on('message', (data, isBinary) => { + const message = isBinary ? data : data.toString(); expect(message).toBe('foobar'); done(); }); @@ -136,7 +140,8 @@ describe('E2E WebSocket proxy', () => { }); it('should proxy to path', (done) => { - ws.on('message', (message) => { + ws.on('message', (data, isBinary) => { + const message = isBinary ? data : data.toString(); expect(message).toBe('foobar'); done(); }); diff --git a/yarn.lock b/yarn.lock index 1ccf1e53..16951883 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5870,6 +5870,11 @@ ws@^7.3.1, ws@^7.4.5, ws@^7.4.6, ws@~7.4.2: resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== +ws@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.1.0.tgz#75e5ec608f66d3d3934ec6dbc4ebc8a34a68638c" + integrity sha512-0UWlCD2s3RSclw8FN+D0zDTUyMO+1kHwJQQJzkgUh16S8d3NYON0AKCEQPffE0ez4JyRFu76QDA9KR5bOG/7jw== + xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"