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:runevent never gets fired when the test hang on the retry run, Thetest:after:runevent is supposed to happen after theafterEachandafterMocha hooks run - We get an
onMocha hookoutput, which means that theafterEachhook has started - We never receive an
onMocha hook endoutput. This signifies theafterEachhook has never finished. So theafterEachhook is hanging for some reason
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
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)
@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?