-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Click and type events in after or afterEach hook don't work if one test fails #2831
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Any workaround for this one? |
I'm having the same issue. In the afterEach i need to perform cleanup after each test, undoing certain UI actions, but if the test failed, any action in afterEach doesn't work properly. I have to do a weird workaround for now, having my clean up code in beforeEach, but, it won't perform clean up on the last test, so I need to also add a dummy test to the very end. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Is this not fixed yet? Really need an approach to run a few code even if tests fail! |
Having the same issue in afterAll() when a testcase fails! I'm using cypress version 8, and have been relying of afterAll() to perform cleanup after test execution. |
Still expirience this issue in version 9.7.0 |
I'm not sure if I ran into the same issue, but I had a problem with a couple clicks not working in an |
Problem still exists in v10.2.0 |
As a temp solution I just add another it hook for data cleanup (not nice) |
The only way for now is to add dummy test which will always be passed. |
why has not it fixed since 2018? Its really annoying bug ^( |
I still have the issue in 12.7 , but there is a workaround you can use |
Can we please get a fix for this? |
Is this a joke, it passed like 4 years and haven't been fixed since ? |
Hello! I encountered the same thing. If test fails - some of the components stop reacting to click() in afterEach hook. Even "force click" is not helping... Cypress V12.7. Are there any more suggestions? I have a lot of tests and they are all failing because of this issue... |
I do encounter this issue too. After some investigation, here are some workarounds which works for me: For click() API, Cypress.$(cssSelector).trigger('click') can be used; For type() API, a custom function setInputValue() can work (for React); const setInputValue = function (input: any, value: any) {
const lastValue = input.value;
input.value = value;
const event: any = new Event('input', { bubbles: true });
// Hack React 15
event.simulated = true;
// Hack React 16
const tracker = input._valueTracker;
if (tracker) {
tracker.setValue(lastValue);
}
input.dispatchEvent(event);
}; And, cy.wait() works in this situation, so you can use it to wait if you have to. |
I understand using the after hook is discouraged (https://docs.cypress.io/guides/references/best-practices#Using-after-or-afterEach-hooks) and we actually clean up right before each test run, but I find it quite frustrating having to launch the tests again and stop it 1 second later only for the app (DDBB) to have the initial state. Furthermore, I dont get why the code fails in the after hook even if discouraged, it's still a bug, right? Thanks! |
5 years with no solution is quite a let down as this is causing a major issue in data cleanup for us. Our initial approach was to have it clean up on a blank test to start however if the previous set ran without issue then there would be no data to clean and thus fail the afterEach hook thus failing the rest of the run. So frustrating |
I actually cannot use force click as my after hook fails on loading a page and checking that intercepted call has status 200, it just doesn't wait as expected. I spent half a day thinking I must have made a mistake, but same code works if test pass and it actually looks like same rootcause. |
I've been having the same issue for days! Just stumbled across the workaround to add a test to the end of the run that will always pass. This solves the problem for the after all hook. I'm not using after each so can't comment on that. Needs to be fixed though! |
This issue is still reproducible on Cypress 13.6.4 |
Current behavior:
Any click event in the after block fails if one of the tests in an it block fails.
Desired behavior:
Click events in the after block should succeed even if there are tests that fail.
Steps to reproduce:
I forked the cypress-tiny-test repository and set up a reproducible example in the latest commit.
https://github.com/StanFisher/cypress-test-tiny
Here's the commit containing the failing after block.
StanFisher/cypress-test-tiny@c185242
Notice that if the failing test is changed to succeed, then the two click events in the after block succeed.
Versions
Cypress 3.1.2
macOS Mojave 10.14.1
Chrome 70.0.3538.102
The text was updated successfully, but these errors were encountered: