cypress: [setupNodeEvents] on("before:spec", ()=>...) doesn't await the promise returned by the event handler
Current behavior
The promise returned by the event handler of before:spec is not awaited but is run concurrently, alongside the spec.
Desired behavior
As specified in the docs here: https://docs.cypress.io/api/plugins/before-spec-api#Syntax, before:spec is supposed to await the completion of the promise returned by it before running the spec.
Test code to reproduce
See https://github.com/ioannisNoukakis/cypress_before_spec_promise, contact me if any questions
Cypress Version
10.11.0
Node version
v16.17.0
Operating System
Manjaro 22.0.0 Sikaris - x86_64 Linux 5.15.74-3-MANJARO
Debug Logs
No response
Other
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 20 (11 by maintainers)
@ioannisNoukakis, thanks for logging this issue and providing the reproduction! I was able to reproduce the issue.
I am going to route this issue to the appropriate team.
Related to: https://github.com/cypress-io/cypress/issues/23627, https://github.com/cypress-io/cypress/issues/22360
Actually! @mschile pointed out that the work for
runandopenmode could be broken out into two fixes because theopenmode run events are still experimental and sadly at this time not in the best shape (#23627).I’m going to clean up my branch and see this get across the line for
runmode.@jhulme / @alexniculae I apologize that this hasn’t been prioritized. I have been able to spend a few hours on this and have this fixed for
runmode, however, more work is needed to successfully implement inopenmode. Specifically, it works inopenmode when selecting a spec and allowing it to run, however selecting a spec, then quickly pivoting and selecting a different spec is not correct - you observer the first spec’sbefore:specpromise to resolve and the first spec to start executing when it should be executing the second spec.Here is the branch with the progress: emily/before-spec-promise
If you are interested in collaborating to get this across the line, that would be greatly appreciated! Essentially we need to cancel the first promise and/or correctly respond to & execute the last promise that finalizes.
@ioannisNoukakis We would love your contribution!
@emilyrohrbough If no one has started to fix this I’m willing to contribute
@emilyrohrbough, I’d love to, but for full transparency, that is very likely over my level of competences when it comes to coding 🙂
No real rush from my end to update to v10 or 11, just that we’re missing out on some nice new features, bug fixes and everything else that is coming with newer versions.