This issue has come up while migrating @msw/playwright to the new network source architecture.
Description
When constructing an implementation of the WebSocketNetworkFrame, it requires a WebSocketClientConnection and WebSocketServerConnection connection. This results in errors when providing WebSocket(Client|Server)ConnectionProtocol implementations.
const frame = new PlaywrightWebSocketNetworkFrame({
connection: {
client: new PlaywrightWebSocketClientConnection(route),
server: new PlaywrightWebSocketServerConnection(route),
info: { protocols: [] },
},
})
- client: Type 'PlaywrightWebSocketClientConnection' is missing the following properties from type 'WebSocketClientConnection': socket, transport, [kEmitter$1]
- server: Type 'PlaywrightWebSocketServerConnection' is missing the following properties from type 'WebSocketServerConnection': client, transport, createConnection, mockCloseController, and 7 more.
Furthermore, it results in errors when passing protocol implementations to webSockerHandler.run(...).
Proposed Solution
As pointed out here, this seems to be a bug since WebSocket(Client|Server)ConnectionProtocol is the intended way for working with WebSocketNetworkFrame.
I'm getting the WebSocketConnectionData from the Interceptors as-is, but that's a mistake. That type is a narrower type than what the frame should care about.
We should probably annotate that connection option as WebSocketHandlerConnection from WebSocketHandler.ts, which contains the broader WebSocketClientConnectionProtocol.
This issue has come up while migrating
@msw/playwrightto the new network source architecture.Description
When constructing an implementation of the
WebSocketNetworkFrame, it requires aWebSocketClientConnectionandWebSocketServerConnectionconnection. This results in errors when providingWebSocket(Client|Server)ConnectionProtocolimplementations.Furthermore, it results in errors when passing protocol implementations to
webSockerHandler.run(...).Proposed Solution
As pointed out here, this seems to be a bug since
WebSocket(Client|Server)ConnectionProtocolis the intended way for working withWebSocketNetworkFrame.