cypress-documentation icon indicating copy to clipboard operation
cypress-documentation copied to clipboard

Websocket Documentation Missing or Hard to Find

Open LawJolla opened this issue 7 years ago • 5 comments

Tremendous work on Cypress! I'm a solo dev that always found testing a nuisance, but now it's part of my work flow thanks to you!

Cypress mentions " You can control WebSocket messages from within Cypress, conditionally load 3rd party scripts, or call functions directly on your application." https://docs.cypress.io/guides/overview/key-differences.html#New-kind-of-testing

I'm running Apollo/GraphQL on the front end, and I would like to mock several web socket frames.

But I cannot find any docs or API for web socket hooks. Websockets are tricky because they need a stateful, persistent server, and it doesn't look like cy.server() provides that, so I'm not sure where to begin.

Any help is appreciated!

LawJolla avatar Apr 27 '18 17:04 LawJolla

In https://docs.cypress.io/faq/questions/general-questions-faq.html#We-use-WebSockets-will-Cypress-work-with-that there's:

We use WebSockets, will Cypress work with that?

Yes.

Shouldn't that be changed to No, or at least an explanation that you can't mock/stub/route it? I'm not sure what the Yes means at all.

/cc @jennifer-shehane

dwelle avatar Feb 19 '19 11:02 dwelle

@LawJolla @dwelle I've created small lib to "mock" WebSockets that works with Cypress, maybe someone will find it useful

Example:

  • https://github.com/baal-cadar/manual-web-socket-example/blob/master/cypress/integration/mws-without-comments.spec.js

Repository & npm:

  • Cypress example: https://github.com/baal-cadar/manual-web-socket-example
  • npm page: https://www.npmjs.com/package/manual-web-socket

baal-cadar avatar May 02 '19 10:05 baal-cadar

@baal-cadar looks interesting..

dwelle avatar May 02 '19 19:05 dwelle

Any updates?

samlucax avatar Jul 11 '20 18:07 samlucax

When can we expect websockets to be supported by cypress? That would narrow down the problem of having to many 3rd party dependencies, which cypress was intended to prevent and be a "all in one solution". (Think of selenium ,etc...)

Drecu avatar Aug 04 '20 13:08 Drecu