playwright-msw icon indicating copy to clipboard operation
playwright-msw copied to clipboard

Feature request: web-socket support

Open GilPasi opened this issue 11 months ago • 0 comments

Starting from version v2.6.0 (2024-10-29) of MSW, there was a support for web-socket mocking. I did not find any complementary interface for those mocks. Specifically when I use the createWorkerFixture method I can pass the WebSocketHandlers object from MSW but I get a type error:

function connectionMessage(){
//Implementation ...
}

const fullPath = "ws://fullpath"

handlers=[
// REST handlers...
ws.link(fullPath).addEventListener("connection", connectionMessage)
]

createWorkerFixture([...handlers])

Argument of type '(WebSocketHandler | HttpHandler)[]' is not assignable to parameter of type 'RequestHandler<RequestHandlerDefaultInfo, any, any, RequestHandlerOptions>[]'. Type 'WebSocketHandler | HttpHandler' is not assignable to type 'RequestHandler<RequestHandlerDefaultInfo, any, any, RequestHandlerOptions>'. Type 'WebSocketHandler' is missing the following properties from type 'RequestHandler<RequestHandlerDefaultInfo, any, any, RequestHandlerOptions>': info, isUsed, resolver, log, and 6 more.ts(2345)

It would be awesome to get such support for this 👍🏾

GilPasi avatar Jan 19 '25 15:01 GilPasi