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

cy.visit() loads blank page on an app using the hash router #210

Open
aubincc opened this issue Jun 19, 2023 · 5 comments
Open

cy.visit() loads blank page on an app using the hash router #210

aubincc opened this issue Jun 19, 2023 · 5 comments

Comments

@aubincc
Copy link

aubincc commented Jun 19, 2023

Inspired from cypress-io/cypress#27050

Current behavior

If my Web app uses the hash router, I cannot seem to be able to visit the same url twice.

If I have Cypress.env("baseUrl") = "https://my-example-app.com/"

I cannot have cy.visit("#/login") or cy.visit("https://my-example-app.com/#/login") in the first and the second it().
I cannot have it in a beforeEach() hook with two tests either.

However cy.visit("") and cy.visit("https://my-example-app.com/") work well, even though I am redirected by the page to #/login immediately.

image

Desired behavior

The cy.visit("#/login") in the second it() or second trigger of beforeEach() should load the page correctly.

Test code to reproduce

describe("Visit login page", () => {
  it("Working", () => {
    cy.visit("#/login"); // loads page correctly
    cy.get("img.logo").should("be.visible"); // finds the logo image 
  });
  it("Page is blank", () => {
    cy.visit("#/login"); // loads a blank page
    cy.get("img.logo").should("be.visible"); // does not find the logo image 
  });
});

Pivot point

I have this behaviour when cypress\support\e2e.(ts|js) contains import "@bahmutov/cy-api";.

This problem is gone when I comment it out.

Cypress Version

v12.14.0

Node version

v18.16.0

Operating System

Windows 11 Pro 22H2 Build 22621.1702

Debug Logs

No response

Other

No response

@bahmutov
Copy link
Owner

bahmutov commented Jun 19, 2023 via email

@aubincc
Copy link
Author

aubincc commented Jun 19, 2023

I will try and find the pivot point where this behaviour comes and goes. I do not have a clue yet, but I will try harder in the next couple of days.

Do you have baseUrl set in your config?

Originally I had the backend url as baseUrl because I use cy.api() a lot.

I have also tried setting the baseUrl to the frontend, but it did not change.

For the moment, this behaviour disappears when I comment out the import of this plugin.

Do you have fallback route in your backend

No

@bahmutov
Copy link
Owner

bahmutov commented Jun 19, 2023 via email

@aubincc
Copy link
Author

aubincc commented Jun 20, 2023

testIsolation: false seems to be what causes pain


Reproducible example

https://github.com/aubincc/bahmutov-cy-api-testIsolation-false

Lines to fiddle with

@aubincc
Copy link
Author

aubincc commented Jun 21, 2023

I could try and find a fix, but I do not know where to log what is happening.

I have been looking, but I have no clue. Sorry I tried

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

2 participants