question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress doesn't work when there is no internet connection, testing to localhost

See original GitHub issue

Current 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:

image

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:

  1. Clone this repo, then npm install. This repo is just create-react-app with a cypress test that visits the home page.
  2. Disconnect internet connection.
  3. npm start to start server. http://localhost:3000 should display the default page for create-react-app.
  4. 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:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
flotwigcommented, Jul 22, 2019

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 use os.networkInterfaces() to detect if this problem is going to occur, and if so, strip the problematic flag from dns.lookup. Submitted a PR to fix this (#4774) while we work on upgrading the bundled Node (#3568)

1reaction
brian-manncommented, Jul 19, 2019

Cypress should most definitely work offline, @flotwig can you take a look at this?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found