Skip to content
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

Browser refreshes twice on initial load #2542

Closed
lmiller1990 opened this issue Sep 28, 2018 · 5 comments
Closed

Browser refreshes twice on initial load #2542

lmiller1990 opened this issue Sep 28, 2018 · 5 comments

Comments

@lmiller1990
Copy link
Contributor

Current behavior:

When initially opening the UI using yarn cypress:open, for example, the tests start running, then the page refreshes. I made a youtube video about it:

https://www.youtube.com/watch?v=UzI5W9Lqm8A&feature=youtu.be

around 0:14 you can see the tests start running. Then at 0:18, for some reason, the browser (or iframe?) refreshes.

This causes the beforeEach hook to trigger twice, which is causing problems for me (reseeding the database twice).

One the UI is open and running, everything is fine. However, due to the beforeEach hook triggering twice, my first test run always fails.

Desired behavior:

The page should not refresh.

Steps to reproduce:

Open the Cypress interface. It seems consistent, at least on my machine.

Versions

Cypress: 3.1
MacOS: 10.13.12

@chrisbreiding
Copy link
Contributor

This is expected behavior. When Cypress originally loads, it's on a random localhost port. Then when you cy.visit() in your test, it 're-loads' at localhost:3000, which is necessary to prevent cross-origin issues. You can prevent the 're-load' and have Cypress load directly on localhost:3000 by setting the baseUrl in your cypress.json.

@lmiller1990
Copy link
Contributor Author

it worked! thanks. cypress is the best.

@davidorgan
Copy link

I was seeing a similar issue, so set baseUrl and it appears to have helped. I'm commenting as it's also worth noting this seems to have fixed my intermittent issue with users login session not always being cleared between tests.

@davidzambrana
Copy link

I had the same issue though it wasn't a real problem in my case to have this duplicates; shifted to use baseUrl and they look much better now.

Thanks for raising this one.

@mcmillion
Copy link

Yep, I just ran into a similar issue where my beforeEach (which cleans the database) was running twice because of the page refresh and causing issues with my login setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants