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

Alias for intercept is not working if overwriting cy.intercept command #9580

Closed
bahmutov opened this issue Dec 9, 2020 · 5 comments · Fixed by #9596
Closed

Alias for intercept is not working if overwriting cy.intercept command #9580

bahmutov opened this issue Dec 9, 2020 · 5 comments · Fixed by #9596

Comments

@bahmutov
Copy link
Contributor

bahmutov commented Dec 9, 2020

Cypress v6.1.0

describe('intercept', () => {
  Cypress.Commands.overwrite('intercept', (intercept, ...args) => {
    return cy.log('intercept!').then(() => {
      return intercept(...args)
    })
  })

  it('is registered too late', () => {
    cy.visit('/')
    cy.intercept('/todos').as('todos')
    cy.wait('@todos')
  })
})

The alias todos is not recognized, but the routes table is showing it

Screen Shot 2020-12-08 at 9 35 57 PM

Note: even putting cy.wait into cy.then does not solve it - something is really off about this alias.

@bahmutov
Copy link
Contributor Author

bahmutov commented Dec 9, 2020

Similar issue #3890

Another note: using function instead of arrow functions does not resolve the problem

@jennifer-shehane
Copy link
Member

I think this may be related to this issue? Not sure. #5101

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Dec 9, 2020
@bahmutov
Copy link
Contributor Author

bahmutov commented Dec 9, 2020

Ughh, it does not "understand" that the command returns an XHR request

Cypress.Commands.overwrite('intercept', function (intercept, ...args) {
  return cy.log('intercept!').then(function () {
    return intercept(...args)
  })
})
cy.intercept('/foo', 'my value').as('netAlias')
cy.wait('@netAlias')

Screen Shot 2020-12-09 at 12 28 48 PM

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: needs investigating Someone from Cypress needs to look at this stage: work in progress stage: needs review The PR code is done & tested, needs review labels Dec 9, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 11, 2020

The code for this is done in cypress-io/cypress#9596, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Dec 11, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Dec 21, 2020

Released in 6.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.2.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants