Skip to content

Intercept doesn't catch all requests. #16451

Closed
@jennifer-shehane

Description

@jennifer-shehane

Current behavior

I've set up cy.intercept() for a request that goes out quickly 3 times. Each has a times to respond once. Sometimes when this test is run, it hangs on the last cy.wait() even though all 3 requests did occur.

Test code to reproduce

https://github.com/jennifer-shehane/cypress-intercept-times-flake

it(`test`, () => {
  cy.intercept('https://jsonplaceholder.typicode.com/todos/1', { times: 1 }, { title: 'baz' }).as('getTodo')
  cy.intercept('https://jsonplaceholder.typicode.com/todos/1', { times: 1 }, { title: 'bar' }).as('getTodo')
  cy.intercept('https://jsonplaceholder.typicode.com/todos/1', { times: 1 }, { title: 'foo' }).as('getTodo')
  cy.visit('/')
  cy.wait('@getTodo')
  cy.wait('@getTodo')
  cy.wait('@getTodo')

  cy.get('#api-response-list li')
    .first().should('have.text', 'foo')
    .next().should('have.text', 'bar')
    .next().should('have.text', 'baz')
})

Screen Shot 2021-05-11 at 2 20 15 PM

Versions

Cypress 7.3.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions