Cypress doesn't work when there is no internet connection, testing to localhost
See original GitHub issueCurrent behavior:
Cypress will not load tests to localhost server when there is no internet connection. This happens in both GUI (cypress open) and command line (cypress run).
I’m experiencing something similar to https://github.com/cypress-io/cypress/issues/4235, but the differences are:
- It only doesn’t work when there is no internet connection.
- When there’s no connection, issue happens with both Chrome and Electron
In the console, I see this:
I’m not in a corporate proxy server.
Desired behavior:
The tests should still run, since I’m only testing a local server.
Steps to reproduce:
- Clone this repo, then
npm install
. This repo is just create-react-app with a cypress test that visits the home page. - Disconnect internet connection.
npm start
to start server. http://localhost:3000 should display the default page for create-react-app.npm run cypress:open
to start Cypress. Then run home.spec.js. You’ll see that the test doesn’t load.
I also included my logs in the repo. See log.txt
.
Versions
Cypress 3.4.0, Windows 10, Chrome 75 and Electron 61
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Testing an Application in Offline Network Mode - Cypress
Modern web applications need to continue working when a network is unavailable, or at least show users the current network status.
Read more >Could not load locally hosted web server in cypress
I am trying to set up a cypress test ...
Read more >End-to-End Testing with Cypress and Auth0
Learn how to programmatically authenticate against Auth0 in your Cypress tests in a manner that adheres to both Cypress and Auth0 best practices....
Read more >Run Cypress tests on private networks | BrowserStack Docs
Learn how BrowserStack Local Testing enables you to test localhost and ... the way it is implemented, only your tests can use your...
Read more >How to troubleshoot LambdaTest Tunnel
The error “localhost refused to connect” occurs because of using the URL as localhost which is unfortunately not compatible with various ...
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 FreeTop 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
Top GitHub Comments
The root issue appears to be nodejs/node#11320… Node on Windows cannot resolve
localhost
when there is no active network interface besides ‘loopback’.A fix landed in Node 8.10: nodejs/node#17662, we’re on 8.9.3.
An interim fix is to intercept calls to
dns.lookup
and useos.networkInterfaces()
to detect if this problem is going to occur, and if so, strip the problematic flag fromdns.lookup
. Submitted a PR to fix this (#4774) while we work on upgrading the bundled Node (#3568)Cypress should most definitely work offline, @flotwig can you take a look at this?