Tests from example_spec.js don't run in Chrome after newly installed cypress
See original GitHub issue- Operating System: macOS Sierra 10.12.6
- Cypress Version: 0.20.1
- Browser Version: Chrome 61.0.3163.91
Is this a Feature or Bug?
Bug
Current behavior:
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.”
Desired behavior:
I’d expect the tests that are included in the example_spec.js would run in browser. instead, nothing appears in the browser
How to reproduce:
- Fresh install of cypress via npm i -D cypress.
- run
node_modules/.bin/cypress open
from command line - click
example_spec.js
in integration tests list - notice that chrome opens, however nothing ever shows up, tests aren’t run
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Troubleshooting
Split large spec files into smaller ones. Split long tests into smaller tests. Run the same test using --browser chrome. The problem might...
Read more >Browser not launched through Cypress problem #1239
When running any test using Chrome, the browser opens and shows the following message: This browser was not launched through Cypress.
Read more >Cypress test runner is not instantly running when the ' ...
Show activity on this post. From the command prompt, first I run this command to go to this directory'cd C:\node_modules. bin ' Then...
Read more >How to Run Cypress Tests in Chrome and Edge
This article will demonstrate how to use Cypress browser website test cases on Google Chrome and Microsoft Edge with examples.
Read more >Module 1 – Intro to saucectl with Cypress
spec.js' . Now when you use the command saucectl run you should see both test suites, chrome smoke and chrome regression having ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 oflocalhost -> 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 atlocalhost
, which should be at127.0.0.1
of course, in most cases anyways.In short, if you’re seeing this, maybe check your hosts file just in case?
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!