I am testing a web app with cypress.
I sign in in my beforeEach function. Then, in my different tests, I begin with cy.visit('mysite.com/url').
My problem is that after sign in, the website redirects to a specific page of the website. This redirection happens after the cy.visit of my tests. Therefore, my tests run on the redirection page, they fail.
The redirection seems to be not linked with any request I could wait for.
I end up with cy.wait(3000) but it is not very satisfying. My tests failed sometimes because the redirection might take more than 3 seconds. I do not want to increase that time because it would take too long to run my tests.
Is there a way to do something like:
while (!cy.url().eq('mysite.com/redirection-url')) {
cy.wait(300);
}