From e09b513392eef415c3b70f86d45d4909c00bab21 Mon Sep 17 00:00:00 2001 From: Steven Luscher Date: Fri, 8 Sep 2023 21:16:02 +0000 Subject: [PATCH] test: upgrade to `mock-socket` with proper `send()` behaviour on `CLOSING` and `CLOSED` --- package.json | 1 + .../__tests__/websocket-connection-test.ts | 10 ++++------ pnpm-lock.yaml | 15 ++++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index a1dff1b31ab5..96d62c34a37a 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "pnpm": { "overrides": { "jsdom": "^22", + "mock-socket": "^9.3.0", "shelljs": ">=0.8.5" } }, diff --git a/packages/rpc-transport/src/transports/websocket/__tests__/websocket-connection-test.ts b/packages/rpc-transport/src/transports/websocket/__tests__/websocket-connection-test.ts index 4c362d6f565c..67a052d79ae5 100644 --- a/packages/rpc-transport/src/transports/websocket/__tests__/websocket-connection-test.ts +++ b/packages/rpc-transport/src/transports/websocket/__tests__/websocket-connection-test.ts @@ -98,17 +98,15 @@ describe('RpcWebSocketConnection', () => { connection.send({ some: 'message' }); await expect(ws).toReceiveMessage({ some: 'message' }); }); - // See https://github.com/thoov/mock-socket/pull/382 - it.failing('does not fatal when sending a message to a closing connection', async () => { - expect.assertions(1); + it('does not fatal when sending a message to a closing connection', async () => { + expect.assertions(2); const client = getLatestClient(); abortController.abort(); expect(client).toHaveProperty('readyState', WebSocket.CLOSING); await expect(connection.send({ some: 'message' })).resolves.toBeUndefined(); }); - // See https://github.com/thoov/mock-socket/pull/382 - it.failing('does not fatal when sending a message to a closed connection', async () => { - expect.assertions(1); + it('does not fatal when sending a message to a closed connection', async () => { + expect.assertions(2); const client = getLatestClient(); abortController.abort(); await ws.closed; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d924acd116bf..e24fdd4f836e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,7 +1,12 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + overrides: jsdom: ^22 + mock-socket: ^9.3.0 shelljs: '>=0.8.5' importers: @@ -8614,7 +8619,7 @@ packages: resolution: {integrity: sha512-M/T3U5qYGoX69846gj1fFUCx8GeaOQRly2zu9mUzxDKU4iXceBwn4AHxxeCc7W6Wn98WxQNtfO+0gr7LYUGrzg==} dependencies: jest-diff: 29.6.1 - mock-socket: 9.2.1 + mock-socket: 9.3.0 dev: true /jest-worker@27.5.1: @@ -9272,8 +9277,8 @@ packages: yargs-unparser: 2.0.0 dev: true - /mock-socket@9.2.1: - resolution: {integrity: sha512-aw9F9T9G2zpGipLLhSNh6ZpgUyUl4frcVmRN08uE1NWPWg43Wx6+sGPDbQ7E5iFZZDJW5b5bypMeAEHqTbIFag==} + /mock-socket@9.3.0: + resolution: {integrity: sha512-TFaQaIxXbzNke3z9nhSnMJFQn8l7QPmF+Luhh8MPHqkmr6B4fPquOTSILCjGUyxDBPv9AFxuaTGmRINDHDmkdQ==} engines: {node: '>= 8'} dev: true @@ -11967,7 +11972,3 @@ packages: /zstd-codec@0.1.4: resolution: {integrity: sha512-KYnWoFWgGtWyQEKNnUcb3u8ZtKO8dn5d8u+oGpxPlopqsPyv60U8suDyfk7Z7UtAO6Sk5i1aVcAs9RbaB1n36A==} dev: true - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false