Nesting hooks within other hooks causes the test to never finish (runs forever)
See original GitHub issueCurrent behavior:
Since upgrading to Cypress 5.0.0, I cannot get any tests to pass. Tests will run through all the code, but when they get to the end, the test does not get marked as passed and the timer keeps counting up.
Desired behavior:
Tests end and move on the next test/spec.
Test code to reproduce
context('Never-ending Test', function () {
it('Test', function () {
cy.visit('http://wikipedia.com')
cy.get('#searchInput')
.type('Cypress.io')
cy.get('.pure-button')
.click()
// Test never ends.
})
it('Next Test', function () {
// Test never starts.
cy.visit('http://wikipedia.com')
})
})
Versions
Cypress 5.0.0 macOS: 10.14.6 Browser: Chrome 84.0.4147.125, Firefox 79, Electron 83
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (8 by maintainers)
Top Results From Across the Web
Infinite loop in useEffect - reactjs - Stack Overflow
Passing an empty array as the second argument to useEffect makes it only run on mount and unmount, thus stopping any infinite loops....
Read more >Avoid Nesting when you're Testing - Kent C. Dodds
Why using hooks like beforeEach as a mechanism for code reuse leads to unmaintainable tests and how to avoid it.
Read more >How to solve the React useEffect Hook's infinite loop patterns
Solve the issue of infinite loops when using the useEffect Hook in React to more smoothly utilize the Hook for your app's side...
Read more >How To Handle Async Data Loading, Lazy Loading, and Code ...
This will let you run your asynchronous code deliberately instead of on ... In this step, you'll use the useEffect Hook to load...
Read more >Changelog - Cypress Documentation
Fixed an issue where the Cypress migration wizard would fail to run in global ... where nesting hooks within other hooks caused the...
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
@todd-m-kemp I thought how to extend our recipe to allow setting global test timeout, here is the solution https://github.com/cypress-io/cypress-example-recipes/pull/549
@Bkucera : Thank you so much for that explanation; I’ve tested it out and it does appear that is exactly what is happening. 😄 I’ll have to rework that section of code to remove the nested hook if the result here is that nested hooks soon won’t be supported.