cypress: Tests hang when afterEach promise does not resolve with Retires enabled

Current behavior

I recently noticed that our e2e tests periodically fail the first run and then randomly hang on the retry run. After outputting cypress logs via DEBUG='cypress:*' I found the following:

  • The test:after:run event never gets fired when the test hang on the retry run, The test:after:run event is supposed to happen after the afterEach and after Mocha hooks run
  • We get an onMocha hook output, which means that the afterEach hook has started
  • We never receive an onMocha hook end output. This signifies the afterEach hook has never finished. So the afterEach hook is hanging for some reason Screen Shot 2022-05-10 at 10 14 06 AM

It appears to me that the tests are hanging when retries are enabled and the afterEach promise does not resolve

Desired behavior

During the first retry, Cypress should reach timeout and fail. The test should not hang.

Test code to reproduce

I am unable to share test code/logs due to proprietary rights. However, I was able to reproduce a similar error where the test hangs on first retry when the done() callback is never invoked.

In cypress.json

"retries": {
    "runMode": 1,
    "openMode": 1
 }

Test Case

describe('Cypress Tests Hang', () => {
  it('Cypress Tests Hang', () => {
    cy.visit('https://www.google.com');
  });

  afterEach(run => {
    cy.log('In afterEach');
  });
});

You’ll see that the first run fails, and the retry run will end up hanging

Screen Shot 2022-05-24 at 2 51 46 PM

Cypress Version

9.7.0

Other

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 3
  • Comments: 15 (3 by maintainers)

Most upvoted comments

@flotwig I was wondering if there’s any estimate on when this will get looked at? We are still running into this issue.

Hi @jennifer-shehane ! This is still causing us issues, I was wondering if anyone has started looking into it yet?