-
Notifications
You must be signed in to change notification settings - Fork 25
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
Comments
Do you have baseUrl set in your config? Do you have fallback route in your backend?Sent from my iPhoneOn Jun 19, 2023, at 09:57, Nicolas AUBIN ***@***.***> wrote:
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.
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 ***@***.***/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
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
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.
Originally I had the backend url as I have also tried setting the For the moment, this behaviour disappears when I comment out the import of this plugin.
No |
Ok then I will need a reproducible example to debug this since there could be so many things in your two apps and specs to say anything definitive Sent from my iPhoneOn Jun 19, 2023, at 10:23, Nicolas AUBIN ***@***.***> wrote:
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
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Reproducible examplehttps://github.com/aubincc/bahmutov-cy-api-testIsolation-false Lines to fiddle with |
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 |
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")
orcy.visit("https://my-example-app.com/#/login")
in the first and the secondit()
.I cannot have it in a
beforeEach()
hook with two tests either.However
cy.visit("")
andcy.visit("https://my-example-app.com/")
work well, even though I am redirected by the page to#/login
immediately.Desired behavior
The
cy.visit("#/login")
in the secondit()
or second trigger ofbeforeEach()
should load the page correctly.Test code to reproduce
Pivot point
I have this behaviour when
cypress\support\e2e.(ts|js)
containsimport "@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
The text was updated successfully, but these errors were encountered: