Skip to content

Investigation - Cypress cy.go('back') does not work with hash routing #5255

Description

@JohannesDoberer

Description

The Cypress command cy.go('back') does not trigger a hash-based back navigation when using useHashRouting: true. The URL remains unchanged and the test hangs indefinitely.

Manually calling window.history.back() in the browser works as expected — the hashchange event fires and Luigi processes the route change correctly.

Steps to Reproduce

  1. Configure Luigi with the config below
  2. Visit the app via cy.visit('http://localhost:4900/#/')
  3. Navigate programmatically: Luigi.navigation().navigate('/projects/pr1/dps')
  4. URL resolves to /#/projects/pr1/dps/dps2 (via defaultChildNode)
  5. Call cy.go('back')
  6. Expected: URL changes to /#/home
  7. Actual: URL does not change, test hangs

Luigi Config

{
  navigation: {
    nodes: [
      {
        pathSegment: 'home',
        label: 'Home',
        icon: 'home',
        viewUrl: '/multipurpose.html',
      },
      {
        pathSegment: 'projects',
        label: 'Projects',
        icon: 'folder',
        viewUrl: '/multipurpose.html',
        children: [
          {
            pathSegment: 'pr1',
            label: 'Project One',
            viewUrl: '/multipurpose.html',
            children: [
              {
                pathSegment: 'dps',
                label: 'Default Child node Example',
                defaultChildNode: 'dps2',
                children: [
                  {
                    pathSegment: 'dps1',
                    label: 'First Child',
                    viewUrl: '/multipurpose.html',
                  },
                  {
                    pathSegment: 'dps2',
                    label: 'Second Child',
                    viewUrl: '/multipurpose.html',
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  routing: {
    useHashRouting: true
  }
}

Environment

  • Cypress 15.x
  • Luigi core-modular with useHashRouting: true
  • Browser: Chrome

Analysis

cy.go('back') internally calls history.go(-1) but then waits for a page load event. With hash routing, only a hashchange event fires (no full page load), so Cypress never resolves.

Using win.history.back() directly causes Cypress to detect a navigation and show "waiting for new page to load" — also incorrect for hash changes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions