New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
afterEach hook is triggered after test runner was stopped. #8621
Comments
A workaround suggestion would be also useful. If there is a way to programmatically check whether the test was stopped, then I could skip the code inside the afterEach method. |
There's a PR up for a fix, as a workaround you can detect if the runner has been stopped via: Cypress.mocha.getRunner().stopped |
Thanks for the workaround idea! It works nicely. |
The code for this is done in cypress-io/cypress#8622, but has yet to be released. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
I can't effectively stop the interactive test runner with the stop button (black rectangle). The test stops, but the interrupted command (e.g.
cy.get()
,cy.click()
) hits a timeout and thenafterEach
hook is triggered.In our environment,
afterEach
hook closes the site what we are testing, so If I stop the test runner I have only some seconds (defaultCommandTimeout
) to check the DOM elements in the debugger tools until the interrupted command times out and the site is closed. I think the test runner should stop where it is, so I can interact with the site anytime.For example in an environment, where there are iframes, I can't get the DOM state after the test finished, because cypress does not record it correctly. So it would be useful if I could stop the test and check the live site instead.
Current behavior:
Stoping a
cy.get()
orcy.click()
command will time out and triggerafterEach
hook.Desired behavior:
Stoping a
cy.get()
orcy.click()
command should not triggerafterEach
hook, but should stop the test execution entirely.Test code to reproduce
There is a simple test code bellow. Since there is no item with the ID
#holy-grail
you can easily stop the test runner while it is trying to find that item. Try to interrupt thecy.get()
command. It stops, but it will time out. I can see also the time out progress bar moving. After the timeout, afterEach hook is run and the test leaves the original site, so I can't interact with it.Versions
cypress version: 5.1.0
browser: chromium 78.0.3904.108
OS: openSUSE Leap 15.0
The text was updated successfully, but these errors were encountered: