badeball / cypress-cucumber-preprocessor

Run cucumber/gherkin-syntaxed specs with Cypress
MIT License
1.32k stars 147 forks source link

Error: Unexpected state in afterSpecHandler when chrome browser crashes #1172

Closed AMEntwistle closed 6 months ago

AMEntwistle commented 6 months ago

Current Behaviour

When the chrome browser crashes during test execution, an error is thrown and the plugin does not exit gracefully:

Error: Unexpected state in afterSpecHandler: step-started (this might be a bug, please report at https://github.com/badeball/cypress-cucumber-preprocessor)
    at createError (/Users/entw003/Repos/cucumber-cypress-tests/node_modules/@badeball/cypress-cucumber-preprocessor/dist/helpers/error.js:9:12)
    at afterSpecHandler (/Users/entw003/Repos/cucumber-cypress-tests/node_modules/@badeball/cypress-cucumber-preprocessor/dist/plugin-event-handlers.js:276:43)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Object.handler (/Users/entw003/Repos/cucumber-cypress-tests/node_modules/cypress-on-fix/index.js:32:20)

Desired Behaviour

It would be great if the plugin would handle this error. Currently this throws cypress into an exit which means other plugins depending that run after this may not run. In our instance this actually leads to false positives. Chrome memory errors have been an issue with cypress for some time now so being able to handle this scenario would be beneficial.

Test code to reproduce

  1. Add a cy.pause() to a test
  2. Run the test in headed mod, e.g cypress run --env TAGS="@focus" --browser chrome --headed
  3. When you hit the pause, trigger the crash by pasting this into the browser:chrome://inducebrowsercrashforrealz

-->

Versions

badeball commented 6 months ago

Hi @AMEntwistle, I've fixed this with v20.0.3

AMEntwistle commented 6 months ago

Fantastic, thank you @badeball

Rachel-BAO commented 2 months ago

This probleme (or similare) was anew present, you can see the thread here : https://stackoverflow.com/questions/78687721/unexpected-state-in-beforespechandler-uninitialized-while-running-feature-file/

badeball commented 2 months ago

@Rachel-BAO, if you're trying to solicit help, then you need to follow contributing guidelines. This almost always entails providing a reproducible example.