-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
#27050
Comments
Verified on an app with React's hash router (requiring Node 16): https://codesandbox.io/s/react-hash-router-juo2v describe("Visit login page", () => {
it("Working", () => {
cy.visit("http://localhost:3000/#/about");
cy.get("#root > div > h1").should("contain.text", "Single Page App");
cy.get(".navbar > li").first().should("contain.text", "Home").next().should("contain.text", "About").next().should("contain.text", "Portfolio Details");
cy.get("main h1").should("contain.text", "About");
});
it("Page is blank", () => {
cy.visit("http://localhost:3000/#/about");
cy.get("#root > div > h1").should("contain.text", "Single Page App");
cy.get(".navbar > li").first().should("contain.text", "Home").next().should("contain.text", "About").next().should("contain.text", "Portfolio Details");
cy.get(".about > h1").should("contain.text", "About");
});
it("Working on /", () => {
cy.visit("http://localhost:3000/");
cy.get("#root > div > h1").should("contain.text", "Single Page App");
cy.get(".navbar > li").first().should("contain.text", "Home").next().should("contain.text", "About").next().should("contain.text", "Portfolio Details");
cy.get("main h1").should("contain.text", "You're home!");
});
}); |
Hi @aubincc 👋, thanks for logging this issue. Unfortunately, I haven't been able to recreate the issue. I create a test project(branch |
Hi @mschile and thank you, I certainly should have tested further, with the minimum, just like you did. The problem seems to be coming from this Cypress plugin that I use: I tested by removing the " I tested with |
Per the above comment, this does not appear to be an issue with Cypress. As such, I am going to go ahead and close this issue. |
Current behavior
When I test my company's vue app, which uses the hash router, I cannot seem to visit the same url on the second test.
If I have
Cypress.env("baseUrl") = "https://my-example-app.com/"
I cannot have
cy.visit("#/login")
orcy.visit("https://my-example-app.com/#/login")
in a secondit()
or in abeforeEach()
hook.However
cy.visit("")
andcy.visit("https://my-example-app.com/")
work well, even if I am redirected by the page to#/login
immediately.I have this behaviour regardless of the
testIsolation
value.Desired behavior
The
cy.visit("#/login")
in the secondit()
or second trigger ofbeforeEach()
should load the page correctly.Test code to reproduce
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
The text was updated successfully, but these errors were encountered: