-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Cypress loads page twice on first visit, even if baseUrl is set #15523
Comments
Do you have an example of the test code? |
Thanks for the response. Just the most minimal test code causes the problem:
As you can see by the following screenshot, index.html is loaded twice after one call to |
Same behavior for us |
This might be the same thing (or perhaps just related) that I reported back in January? #14538 |
I don't think so, since my use case doesn't involve changing domain during the test. Your behaviour might actually be the expected behaviour (see #2542) (don't quote me on this :D). |
Adding baseUrl will resolve the problem. If your base url is inside env: { baseUrl : "blah blah"} this won't work. It has to be like baseUrl: "blah blah" inside cypress config file |
I have the same problem. I added the baseUrl and it was ok but now I am running the tests against the app that is running on my local machine. I changed the baseUrl to go to the new site (which is now local) but now it loads the first visit() twice. The only thing that is changed is the baseUrl because now I build the app that I am testing locally. Could that be the problem? |
I found the solution. The problem was that when I changed the URL I was still using HTTPS as it was before but there was no self-signed certificate or cypress couldn't find it (the app is running in docker) and that is the reason why it would start 2 times at the beginning of each spec file as when you use only cy.visit() withouth baseUrl. The reason for this is that cypress creates its one self-signed certificate and restarts again with the certificate. The solution was to use HTTP. |
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided. |
This issue has been closed due to inactivity. |
Current behavior
When calling
npx cypress open
and running the test for the first time (those two conditions are needed to reproduce), the page is loaded twice on the firstcy.visit
. I have added aconsole.log
in my index.html and can clearly see that this one call ofcy.visit
makes the html load twice.This issue suggests that this behaviour can be avoided by setting a
baseUrl
in the cypress.json, but that is not the case - there might be a regression bug. This is my cypress.json:I don't have Chrome installed on my machine currently, so it's using Electron to run tests.
Desired behavior
index.html should not be loaded twice on first call to
cy.visit
Versions
Using v6.7.1
The text was updated successfully, but these errors were encountered: