cy.visit() loads blank page on an app using the hash router
- Dominant language
- TypeScript
- Stars
- 210
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Description
> _Inspired from https://github.com/cypress-io/cypress/issues/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
```javascript
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_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the two-test reproduction and cypress\support\e2e.(ts|js), first running it with import "@bahmutov/cy-api" and then without that import. Compare the first and second cy.visit("#/login") results and the img.logo assertion. Done means repeated hash-router visits load the page and find the logo.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100