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.

Testing Breaks Due to Page Redirect

See original GitHub issue

Current behavior:

I must go through a login of a different app in order for my own app to be working, I can’t mock that. So the first line I do is as described below - I use cy.visit(..) to go to that page an log in. However, often when it starts the test, instead of visiting that page and fill the form to login, the entire Chrome tab goes redirects there (rather than just the app on the righthand side panel) and the testing panels are gone as if I just opened a new tab in Chrome and went to that page. I have to kill the cypress process and restart it. That usually fixes it, if not I just restart it a couple more times.

Desired behavior:

Testing proceeds as normal.

Steps to reproduce:

Maybe try to visit a different domain?

cy.visit(`https://different.app.com/session?redirect=${encodeURIComponent(myAppUrl)}`);

Versions

Cypress: 2.1.0 OS: MacOS High Sierra 10.13.3 Browser: Chrome 66

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

13reactions
ghostcommented, Jul 2, 2019

@brian-mann i’m not sure why this is closed. this is a really big blocker for us as well and can’t get passed this redirect bug. Already wrote a LOT of tests for Cypress and would hate to have to move to something else because of something so silly.

Usecase: /page immediately redirects to /page/hi but there is no way to test that this redirect happens. Cypress throws a 404 for some reason when the browser clearly redirects for the end user.

   it('properly load menu url', () => {
   	// Page should probably redirect to a default landing if plugged in randomly.
   	cy.visit('/page')
   		.location('pathname', { timeout: 10000 })
   		.should('eq', '/page/hi');
   });
3reactions
ricovitchcommented, Jun 12, 2018

Hello,

We are actually evaluating which solution to use for end2end testing in our project. Cypress seems great, it has a nice developer experience, and good documentation/examples/etc.

But we hit a wall with the login step of our backoffice application because of the iframe/multiple domains restrictions. I know there are a lot of informations and even a sample on how to get this kind of scenario working, but as we are not the team developing the backend and the authentification services, this is just a show stopper for us…

That and a straight forward way of running multiple test suites in parallel without a docker master degree

Sorry i don’t want to seem rude, but i’m actually sad that we can not go further with cypress, as i feel it has great potential. I just wanted to share that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing redirect with Cypress
I decided to create a small test case to verify that the redirect functionality works well for pages with updated URL addresses.
Read more >
Create a redirect test - Optimize Resource Hub - Google Support
A redirect test is a type of A/B test that allows you to test different web pages against each other. A redirect test...
Read more >
Testing redirects before and after a website migration
In this article, you will learn everything you need to know about testing your redirects before and after a website migration.
Read more >
Dealing with multiple redirects in Cypress - Filip Hric
Our redirect happens just too fast. Since Cypress waits for page to fully load, our assertion comes in too late and our test...
Read more >
How to test javascript redirection without redirecting?
I have faced this same problem. My solution was to break out the actual redirect into a single purpose function. That is, don't...
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