fix: actionability not retrying in after hooks where the test failed #30831
+94
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Additional details
When an action (such as click or type) is performed in an
after
hook where the test has failed, the actionability check is not retried and the click/type/other action? does not execute as expected. This is because Cypress is seeing that state('error') is set (since the test failed) and exiting because it believes the current runnable is in an error state so should stop retrying the check.cypress/packages/driver/src/cy/actionability.ts
Line 621 in c50a138
In actuality, we're in a different runnable - where the state has not errored. So we should continue retrying in the new runnable where the error is not present.
To fix the issue, I removed the check for
state('error')
altogether in the retries logic. This seems like it was put there for a purpose - and that tests would fail if you remove it, but all of our tests pass. I'm assuming that logic changed at some point where the condition is met properly regardless of this check now, but it'd be great to have some deeper verification.Steps to test
Added tests to click.ts and type.ts although I feel like this isn't quite the right place for this logic since it's addressing an issue in retries, but no unit tests are there.
How has the user experience changed?
Click and type in after hooks now execute properly.
PR Tasks
cypress-documentation
?type definitions
?