Bug
Clicking example_spec.js opens up chrome browser but no tests appear. Theres also a console.warn stating "WebSocket connection to 'ws://localhost:8080/__socket.io/?EIO=3&transport=websocket' failed: WebSocket is closed before the connection is established."
I'd expect the tests that are included in the example_spec.js would run in browser. instead, nothing appears in the browser
node_modules/.bin/cypress open from command lineexample_spec.js in integration tests listFrom gitter chat:
Mike Joyce @mcMickJuice 10:37
hello, i cant get the example tests to run. after following the "installing cypress" to a T, the GUI launches and when I click on example_spec.js, chrome launches but nothing appears on the screen. there is a console.warning that states ":65417/__/#/tests/integration/example_spec.js:1 WebSocket connection to 'ws://localhost:65417/__socket.io/?EIO=3&transport=websocket' failed: WebSocket is closed before the connection is established."
can anyone help?
Jennifer Shehane @jennifer-shehane 10:39
@mcMickJuice So, we run the example tests by default on port 8080, I think I've encountered this error when I had another process running on 8080
Mike Joyce @mcMickJuice 10:39
ah ha!
Jennifer Shehane @jennifer-shehane 10:39
But, I thought that was also combined with having cypress open with a project also running 8080.
Mike Joyce @mcMickJuice 10:39
yes its launching at a different port. i'll kill whatever process is usingthat port
Jennifer Shehane @jennifer-shehane 10:39
I guess I should have opened an issue ><
Actually, that doesn't sound right either because I think we just visit the example kitchen sink at a public url.
I'll open an issue and find what was specific about it..
Mike Joyce @mcMickJuice 11:01
looks like cypress run hangs too... Timed out waiting for the browser to connect. Retrying...
Jennifer Shehane @jennifer-shehane 11:02
ok, so you're just running the example_spec.js that was generated in a new project that you installed cypress into? using npm install?
Mike Joyce @mcMickJuice 11:02
yep
same issue happening when running on 8080
Jennifer Shehane @jennifer-shehane 11:03
And you're clicking on the 'example_spec' from the GUI? What browser is selected in the GUI in the top right corner?
Mike Joyce @mcMickJuice 11:03
yep, Chrome 61
doesnt work with electron selected either
Mike Joyce @mcMickJuice 11:13
@jennifer-shehane same issue when running on node 6.x
Jennifer Shehane @jennifer-shehane 11:14
@mcMickJuice Yeah, go ahead and open an issue with as much detail as possible. I'm not able to replicate this exact behavior with a fresh install running in Chrome 61. I have seen the websocket error though, so there is some edge case that we're missing that we need defined.
I was unable to replicate this exact behavior, but I have seen the WebSocket connection error before in a strange edge case where I had Cypress open in 2 projects with the same baseUrl set on both to localhost:8080, I'm unfortunately unable to replicate this again though.
This was an issue with my hosts file. I had 127.0.0.1 mapped to a url that mapped to docker but not to localhost. After adding localhost to map to ip4, everything worked!
I'm having similar error. My app when started tries to do some websocket connections (which is actually webpack's dev server hot loading feature), but occasionally those fail (the handling on the server side for this is more convoluted). Anyway, the effect is that app tries to open ws connection and server listens on proper port, but does not support http upgrade at that moment, so server drops connection. Cypress immediately seeing it kills itself, too, without even trying to run anything else, even if I have cy.wait(20000).
@Nopik we need a reproducible repo / issue opened to look at this. As it is right now Cypress runs on tons of projects with websocket connections so there is likely a deeper issue at hand. Would need some direction for us to be able to look at it.
So I had the same issue: launching a Cypress test would open both the Chrome and Electron browser, but nothing would happen, their pages would remain blank.
In the Chrome console, I would see that the Websocket connection could not connect, as the WebSocket would close before the connection would be established.
Turns out that the problem was that for some reason, obscure to me, and almost certainly completely unrelated to Cypress, my hosts file on macOS got removed. That meant that the routing of localhost -> 127.0.0.1 got nuked, and Cypress relies on this mapping. It launches the browser with the assumption that it will find the test runner at localhost, which should be at 127.0.0.1 of course, in most cases anyways.
In short, if you're seeing this, maybe check your hosts file just in case?
Wow, well - the obvious is not always the obvious.
My story in short:
On my Mac I got the hosts.prefPane installed, so I can map lots of URLs to my local development server. Turned out I had to insert a mapping from 127.0.0.1 to localhost to get cypress running.
This, although typing localhost or 127.0.0.1 always returned me the default index page in the Sites folder!
Thx for the fix!
I got logs similar to these. The problem was that my
/etc/hosts
file did not include a line:
127.0.0.1 localhost
Most helpful comment
So I had the same issue: launching a Cypress test would open both the Chrome and Electron browser, but nothing would happen, their pages would remain blank.
In the Chrome console, I would see that the Websocket connection could not connect, as the WebSocket would close before the connection would be established.
Turns out that the problem was that for some reason, obscure to me, and almost certainly completely unrelated to Cypress, my
hostsfile on macOS got removed. That meant that the routing oflocalhost -> 127.0.0.1got nuked, and Cypress relies on this mapping. It launches the browser with the assumption that it will find the test runner atlocalhost, which should be at127.0.0.1of course, in most cases anyways.In short, if you're seeing this, maybe check your hosts file just in case?