Skip to content

cy.intercept() not overriding existing alias properly #20728

@sanjayupasi

Description

@sanjayupasi

Current behavior

In the following test case, firstRoute is not getting overridden by secondRoute, i.e cypress should wait for secondRoute .

Following is the reference screenshot for using cy.intercept()

Screenshot 2022-03-22 at 7 16 33 PM

Desired behavior

In the following test case, firstRoute has to be overridden by secondRoute, i.e cypress should wait for secondRoute .

Following is the reference screenshot for using cy.route()

Screenshot 2022-03-22 at 7 17 30 PM

Test code to reproduce

describe('cy.intercept', () => {
  it('> cy.route overidding', () => {
    cy.intercept('POST', '**/analytics/3.0/results').as('firstRoute')
    cy.intercept('POST', '**/analytics/3.0/results').as('secondRoute')
    cy.visit('/signup')
    cy.wait('@secondRoute')
    cy.contains('button', 'Teacher').should('be.visible')
  })
})

baseUrl: https://www.khanacademy.org/

Cypress Version

9.5.0, 9.0.0, 7.2.0, 7.0.0

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions