My problem is i have a frontend angular that connect with websocket adress x. WS adress x send messages in some format and my frontend will response to it. The messages are really small. Problem i dont have access to the server that send the messages but to a rest api that call it. The post request to that rest api is quite longer and in xml format.
So i need to mock the websocket api and point the frontend to it (websocket adress y) and start the server with the tests in the playwright config...or i need to intercept the connection (websocket adress x) and send my own messages. Both is not possible...
I know that playwright can sniff on websockets in a page and it works as expected. But i cannot find something like page.route() and page.fulfill.
So i would like to have a page.route() AND page.on() where the websocket object has a "send" method so I can mock/intercept websockets
So first approach is for reconnect the page entirely to a new mockserver or other websocket server. Then i could send my messages from this server to the frontend.
🚀 Feature Request
My problem is i have a frontend angular that connect with websocket adress x. WS adress x send messages in some format and my frontend will response to it. The messages are really small. Problem i dont have access to the server that send the messages but to a rest api that call it. The post request to that rest api is quite longer and in xml format.
So i need to mock the websocket api and point the frontend to it (websocket adress y) and start the server with the tests in the playwright config...or i need to intercept the connection (websocket adress x) and send my own messages. Both is not possible...
I know that playwright can sniff on websockets in a page and it works as expected. But i cannot find something like page.route() and page.fulfill.
So i would like to have a
page.route()
ANDpage.on()
where the websocket object has a "send" method so I can mock/intercept websocketsExample
Entire new Mock:
page.route("wss://ownWebsocketUrl")
AND/OR
Intercepting:
So first approach is for reconnect the page entirely to a new mockserver or other websocket server. Then i could send my messages from this server to the frontend.
page.route("wss://localhost:8080")
For Example with this server from ws lib https://github.com/websockets/ws
Motivation