Skip to content

cy.intercept is shown as processing #14655

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

Closed
bahmutov opened this issue Jan 20, 2021 · 4 comments · Fixed by #16730
Closed

cy.intercept is shown as processing #14655

bahmutov opened this issue Jan 20, 2021 · 4 comments · Fixed by #16730

Comments

@bahmutov
Copy link
Contributor

Cypress v6.3.0

In this two test scenario

beforeEach(() => {
  cy.visit('/')
})

it('confirms the number of times an intercept was called', () => {
  cy.intercept('/users?_limit=3').as('users3')
  cy.intercept('/users?_limit=5').as('users5')

  cy.get('#load-users').click().click()
  cy.wait('@users3')

  // to avoid clicking too quickly, add small pauses
  cy.get('#load-five-users').click()
    .wait(20).click()
    .wait(20).click()
    .wait(20).click()
})

it('spies using query parameter', () => {
  cy.intercept({
    pathname: '/users',
    query: {
      _limit: '3',
    },
  }).as('users3')

  cy.intercept({
    pathname: '/users',
    query: {
      _limit: '5',
    },
  }).as('users5')

  cy.get('#load-users').click()
  cy.wait('@users3')

  cy.get('#load-five-users').click()
  cy.wait('@users5')
})

I have noticed that the last XHR of the first test never completes

never-completes.mp4

Reproduction

Repo and branch https://github.com/cypress-io/cypress-example-recipes/tree/runaway-test

  • clone the repo
  • install dependencies
  • cd examples/stubbing-spying__intercept
  • npm run dev
  • click on the spec.js

Note that if there is no second test, or if the first test is it.only then everything is fine, the XHR completes right away. So something about the state is leaking from one test into another I guess

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jan 21, 2021
@flotwig
Copy link
Contributor

flotwig commented Jan 22, 2021

Hmm yeah, all requests are cleared once the test ends, so there is no longer a reference to the log to end it...

Most likely the best fix is to update all unresolved request logs before each test to note that they were incomplete.

@bahmutov
Copy link
Contributor Author

bahmutov commented Jan 22, 2021 via email

@cypress-bot cypress-bot bot added stage: new issues and removed stage: ready for work The issue is reproducible and in scope stage: new issues labels Apr 8, 2021
@flotwig flotwig mentioned this issue Jul 21, 2021
5 tasks
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Aug 2, 2021
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Aug 2, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 2, 2021

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

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 4, 2021

Released in 8.2.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants