Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mock-socket configuration issue ? #364

Open
maxpontreau opened this issue Jul 15, 2022 · 1 comment
Open

mock-socket configuration issue ? #364

maxpontreau opened this issue Jul 15, 2022 · 1 comment

Comments

@maxpontreau
Copy link

Hello,

I working on an Angular projet.
I'm trying to use a real websocket for my production code and the mock-socket for my cypress tests.

Here how I start the websocket in production (using sockjs-client & stompjs librairies)
image

Now maybe I'm mistaken, but I was expected that with this code in cypress, the server would be mocked and the production websocket code would work:
image

When launching cypress the websocket does not succeed to get a connection.

Where am I wrong ?

@Atrue
Copy link
Collaborator

Atrue commented Jul 25, 2022

Is the native WebSocket get called? You can check it by running the cypress in server mode. I'm not sure how the sockjs and stompjs are working.
If so you can try mocking the WebSocket using the cy.stub:

import { WebSocket } from "mock-socket";
...
onBeforeLoad: () => {
  ...
  cy.stub(win, "WebSocket", (url) => new WebSocket(url));
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants