lensesio / cypress-websocket-testing

Test WebSocket connections with Cypress
Apache License 2.0
83 stars 12 forks source link

I keep getting results as undefined #28

Open lefado opened 2 years ago

lefado commented 2 years ago

Hi there!

I am trying to use your library into my project. However, I am not able to read websocket messages. As a PoC, I have used https://websocketstest.com/ site, in order to try to check ws messages. However, I have no luck so far yet.

Code

type MessageType = "CONNECTED" | "LOGIN" | "RECORD" | "END" | "connected" | "version" | "echo" | "time";

interface IMessage {
  type: MessageType;
  data: any;
}

it.only('test 2', function () {
  cy.visit('https://websocketstest.com/')
  const config: WebSocketSubjectConfig<IMessage> = {
    url: "wss://websocketstest.com/service"
  };
  const options = {};
  // Wrap the request in order to bypass the defaultCommandTimeout
  // Investigating alternative solutions      
  cy.wrap(null, { timeout: 10000 }).then(() =>
  cy.streamRequest<IMessage>(config, options).then(results => {
    // debugger      
    expect(results).to.not.be.undefined;
  })
  );
})

Am I missing something?

Thanks in advance