Skip to content

cy.intercept is shown as processing #14655

@bahmutov

Description

@bahmutov

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions