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

Unexpected state in afterSpecHandler after an AssertionError and after each hook throws CypressError when trying to invoke cy.task() #1183

Closed
3 tasks done
bobbhatti opened this issue Apr 26, 2024 · 2 comments

Comments

@bobbhatti
Copy link

bobbhatti commented Apr 26, 2024

Current behavior

This is similar to this previous issue

Chrome/Chroimum is not crashing, but the scenario fails with an AssertionError, which triggers the after each hook

We then see CypressError

CypressError: cy.task() must only be invoked from the spec file or support file.
Because this error occurred during a after each hook we are skipping the remaining tests in the current suite:

An error was thrown in your plugins file while executing the handler for the after:spec event.
The error we received was:
Error: Unexpected state in afterSpecHandler: step-started (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor)

Desired behavior

handle the unexpected state more gracefully, and allow any further scenarios in the feature file to continue

Test code to reproduce

Versions

  • Cypress version: 13.7.3
  • Preprocessor version: 20.0.3
  • Node version: 20.5.1

Checklist

@badeball
Copy link
Owner

Hey, and thanks for reporting this issue. You need to provide a minimal, reproducible example that illustrates the issue.

@badeball
Copy link
Owner

badeball commented May 6, 2024

Closing due to lack of a reproducible example. Feel free to open up another issue if anything changes in this regard.

@badeball badeball closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants