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

Cypress Server Routes Are Lost After Page Load If Not Using cy.visit() #177

Closed
pihish opened this issue Jun 23, 2016 · 5 comments
Closed
Assignees
Labels
type: enhancement Requested enhancement of existing feature type: unexpected behavior User expected result, but got another

Comments

@pihish
Copy link

pihish commented Jun 23, 2016

When I have XHR requests go out on initial page load and need to have Cypress watch for those requests, I have to use cy.visit() to get to the page I want to test. I cannot get directed to that page or else the routes I tell Cypress about are lost.

Example:

cy.visit('https://mydomain.com');
// I am looking for these two XHR requests that are immediately started after my page loads
cy.server().route('GET', /getUsers/).as('getUsers')
           .route('GET', /getApples/).as('getApples');
// By clicking on an element with href value of "/apples", I get directed to a new page
// Cypress will lose the routes I've defined just before this because I've loaded a whole new page
cy.get('#links [href="/apples"]').click().wait(['@getUsers', '@getApples']);

We need a feature where even if a new page loads, the routes you define are not lost. This gives testing a more "natural" flow. cy.visit() is the equivalent of typing in a browser URL. We should be testing how users actually get from page to page, which is usually clicking on a button, or an image, etc...

@jennifer-shehane jennifer-shehane added type: enhancement Requested enhancement of existing feature type: unexpected behavior User expected result, but got another labels Jun 23, 2016
@brian-mann brian-mann self-assigned this Jul 12, 2016
@brian-mann brian-mann added this to the 0.17.x milestone Jul 12, 2016
@brian-mann
Copy link
Member

We need to rewrite the XHR proxy handling to be outside of the browser, which we'll be able to do sometime in 0.17.x

@jennifer-shehane jennifer-shehane removed this from the 0.17.x milestone Feb 3, 2017
@brian-mann
Copy link
Member

The code for this is done, but this has yet to be released. We'll update the issue and reference the changelog when it's released.

@felippepuhle
Copy link

Hi there! Is this still happening? 🤔

@jennifer-shehane
Copy link
Member

@felippepuhle This should have been fixed in 0.20.0, are you experiencing an issue?

@felippepuhle
Copy link

@jennifer-shehane nope! I can't remember what I was doing wrong, but it's 100% now. Sorry didn't answer before, and thanks!

@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement Requested enhancement of existing feature type: unexpected behavior User expected result, but got another
Projects
None yet
Development

No branches or pull requests

4 participants