cypress: Waiting for two identical requests in run mode makes cypress freeze

Current behavior

I have two identical requests issued by an app that I intercept like cy.intercept('GET', '**/user/documents/offering/**').as('getOfferingDocuments') Whenever I wait for them like this

      cy.wait(['@getOfferingDocuments', '@getOfferingDocuments']).should('have.length', 2)
        .then((interceptions) => {
          expect(interceptions[0].response.statusCode, 'first request status').eq(200)
          expect(interceptions[1].response.statusCode, 'second request status').eq(200)
        })

or even like this

      cy.wait(['@getOfferingDocuments', '@getOfferingDocuments'])
      cy.get('@getOfferingDocuments.all').should('have.length', 2)
        .then((interceptions) => {
          expect(interceptions[0].response.statusCode, 'first request status').eq(200)
          expect(interceptions[1].response.statusCode, 'second request status').eq(200)
        })

Whenever I run test in cypress open mode the test passes, but in cypress run mode test just freezes indefinetely with no errors in terminal.

Desired behavior

Same code should be working in run mode as it does in the open mode

Test code to reproduce

     cy.intercept('GET', '**/user/documents/offering/**').as('getOfferingDocuments')

     cy.visit(someUrl)

      cy.wait(['@getOfferingDocuments', '@getOfferingDocuments']).should('have.length', 2)
        .then((interceptions) => {
          expect(interceptions[0].response.statusCode, 'first request status').eq(200)
          expect(interceptions[1].response.statusCode, 'second request status').eq(200)
        })

Cypress Version

10.2.0

Other

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

Just to post my findings - we experienced something similar with our regression. Can confirm that the issue was within our own web app by using a ‘caching mechanism’ which prevented multiple API calls within a timeframe. Cypress was expecting requests and ended up freezing in some runs. The fix (or workaround) here was to use some waits to allow our app to pass the timeframe and resend the request.

Can’t provide a reproducible example since our code is in a private repo and can’t compress this into something that I can share.