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.go('back') broken on hash change from internal links on page #896

Closed
jennifer-shehane opened this issue Nov 9, 2017 · 7 comments
Closed
Labels
pkg/driver This is due to an issue in the packages/driver directory stage: ready for work The issue is reproducible and in scope stale no activity on this issue for a long period type: bug

Comments

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Nov 9, 2017

Current behavior:

Using cy.go('back') to go back to an internal link hash makes Cypress infinitely loop between the baseUrl port and the random port.

Desired behavior:

Being able to use cy.go() to go back to internal links.

How to reproduce:

Test code:

it('cy.go() - go back or forward in the browser\'s history', function(){
  cy.visit('http://localhost:8080#visit')
  cy.visit('http://localhost:8080#reload')
  cy.go('back')
})
<h1 id="visit">Visiting</h1>
<h1 id="reload">Reloading</h1>

Additional Info (images, stack traces, etc)

adding-go

  • Cypress Version: 1.0.3
  • Browser Version: Chrome 61
@jennifer-shehane jennifer-shehane added pkg/driver This is due to an issue in the packages/driver directory stage: ready for work The issue is reproducible and in scope type: bug labels Nov 9, 2017
@jennifer-shehane
Copy link
Member Author

I also had an error prior to running into this error where there were React errors coming from the pkg/reporter about having duplicate children with the same key. And when I clicked on the location command, it would also snapshot the url change. But, now when I run this code, all I get is the infinite looping above, so...this error is hidden in there somewhere, @brian-mann saw it too, I'm perplexed.

This was the test code that was busted

context('Navigation', function(){
  beforeEach(function(){
    cy.visit('http://localhost:8080#visit')
    cy.visit('http://localhost:8080#reload')
  })

  it('cy.go() - go back or forward in the browser\'s history', function(){
    cy.location().then(function(location){
      debugger
    })
    cy.hash().then(function(location){
      debugger
    })
    cy.go('back')
    cy.location().then(function(location){
      debugger
    })
    cy.hash().then(function(location){
      debugger
    })
  })
})

@spearmootz
Copy link

spearmootz commented Jan 4, 2018

We sort of experienced this too. Except it was triggered by clicking a link that triggered window.history.back()

It make the tests run endlessly on headless mode.

@kapalkat
Copy link

kapalkat commented Jul 23, 2018

Hey

The same happens to me. This happens even if my tests are not sharing the same context.
My test looks like follow:

describe('TESTS', function() {
  context('Test1', function() {  
    it('Go to URL1 and do some action', function () {
      // actions
    })
  })
  context('Test2', function() {  
    it('Go to URL2 and do some action and then go back to URL1', function () {
      // actions
      cy.click('back-arrow')
      cy.url(URL1)
    })
  })
})

This test makes cypress to go in the infinite loop.

@samends
Copy link

samends commented Jun 20, 2019

Wanted to bump this issue. I was trying to go between http://localhost:5000/#thing/subitem/7937fb4b-d8c6-4ba8-ae86-5171d85b211/details and http://localhost:5000/#thing/subitem and it wasn't working either

@jennifer-shehane
Copy link
Member Author

This still produces an error state in Cypress 6.4.0, but a different error than before.

it('cy.go() - go back or forward in the browser\'s history', function () {
  cy.visit('https://example.cypress.io/#visit')
  cy.visit('https://example.cypress.io/#reload')
  cy.go('back')
})

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 18, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/driver This is due to an issue in the packages/driver directory stage: ready for work The issue is reproducible and in scope stale no activity on this issue for a long period type: bug
Projects
None yet
Development

No branches or pull requests

5 participants