angrykoala / wendigo

A proper monster for front-end automated testing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Websocket module

angrykoala opened this issue · comments

Investigate possible methods and assertions related to websockets

In order to handle websockets, two alternatives:

    this._page.on("Network.webSocketCreated" as any, ({ requestId, url }) => {
      console.log("Network.webSocketCreated", requestId, url);
    });

    this._page.on("Network.webSocketClosed" as any, ({ requestId, timestamp }) => {
      console.log("Network.webSocketClosed", requestId, timestamp);
    });

    this._page.on(
      "Network.webSocketFrameSent" as any,
      ({ requestId, timestamp, response }) => {
        console.log(
          "Network.webSocketFrameSent",
          requestId,
          timestamp,
          response.payloadData
        );
      }
    );

    this._page.on(
      "Network.webSocketFrameReceived" as any,
      ({ requestId, timestamp, response }) => {
        console.log(
          "Network.webSocketFrameReceived",
          requestId,
          timestamp,
          response.payloadData
        );
      }
    );

These events may work (despite not documented in Puppeteer)

In case these don't, overriding the WebSocket class (WebSocket=class WebSocketMock extends WebSocket)