Skip to content
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

fix: actionability not retrying in after hooks where the test failed #30831

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Jan 7, 2025

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.

return cy.retry(retryActionability, options)

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

Copy link

cypress bot commented Jan 10, 2025

cypress    Run #59827

Run Properties:  status check failed Failed #59827  •  git commit e52626ea6e: empty commit
Project cypress
Branch Review after-hook-action-fix
Run status status check failed Failed #59827
Run duration 18m 03s
Commit git commit e52626ea6e: empty commit
Committer Jennifer Shehane
View all properties for this run ↗︎

Test results
Tests that failed  Failures 1
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 1090
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 26433
View all changes introduced in this branch ↗︎
UI Coverage  45.71%
  Untested elements 191  
  Tested elements 165  
Accessibility  92.54%
  Failed rules  3 critical   8 serious   2 moderate   2 minor
  Failed elements 888  

Tests for review

Failed  cypress/e2e/project-setup.cy.ts • 1 failed test • launchpad-e2e

View Output

Test Artifacts
... > can skip setup CT testing for an E2E project Test Replay Screenshots
Flakiness  commands/waiting.cy.ts • 1 flaky test • 5x-driver-electron

View Output

Test Artifacts
... > throws when foo cannot resolve Test Replay
Flakiness  config_env.cy.ts • 1 flaky test • 5x-driver-electron

View Output

Test Artifacts
cy.origin- Cypress.config() > serializable > overwrites different values in secondary if one exists in the primary Test Replay

@jennifer-shehane jennifer-shehane changed the title fix: actions not running in after hooks that fail fix: actionability not retrying in after hooks where the test failed Jan 10, 2025
@jennifer-shehane jennifer-shehane self-assigned this Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Click and type events in after or afterEach hook don't work if one test fails
1 participant