Tests hang when afterEach promise does not resolve with Retires enabled
See original GitHub issueCurrent 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, Thetest:after:run
event is supposed to happen after theafterEach
andafter
Mocha hooks run - We get an
onMocha hook
output, which means that theafterEach
hook has started - We never receive an
onMocha hook end
output. This signifies theafterEach
hook has never finished. So theafterEach
hook 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
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Resolution method is overspecified”? in beforeEach and ...
When I use done in beforeEach or afterEach I get this error “Error: Resolution method is overspecified” and the test fails. But now...
Read more >Mocha - the fun, simple, flexible JavaScript test framework
simple, flexible, fun. Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun....
Read more >Error Messages | Cypress Documentation
No tests found. This message means that Cypress was unable to find tests in the specified file. You'll likely get this message if...
Read more >Test Lifecycle Events - Node Tap
As of v15, Promises are the only way to use these functions asynchronously. t.afterEach(fn(childTest)). This is called after each child test (or any...
Read more >Frontend testing standards and style guidelines - GitLab Docs
You can also return a promise from the test function. Using the done and done.fail callbacks is discouraged when working with promises. They...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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?