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

[setupNodeEvents] on("before:spec", ()=>...) doesn't await the promise returned by the event handler #24403

Closed
ioannisNoukakis opened this issue Oct 26, 2022 · 20 comments · Fixed by #26055
Assignees

Comments

@ioannisNoukakis
Copy link

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

@mschile mschile self-assigned this Oct 26, 2022
@mschile
Copy link
Contributor

mschile commented Oct 28, 2022

@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: #23627, #22360

@alexniculae
Copy link

@mschile,

  • can you easily tell on which version this issue was introduced?
    • is it affecting all Cypress version 10 releases so far?
  • are there any news or an ETA for the fix?

@alexniculae
Copy link

@emilyrohrbough, just for your information, as I've seen you previously fixed a similar issue #22360

@mschile
Copy link
Contributor

mschile commented Nov 4, 2022

@alexniculae, I believe all versions of Cypress 10 are affected as there were architectural changes that didn't account for the experimentalInteractiveRunEvents functionality. Unfortunately, I do not have an ETA on the fix at this time.

@alexniculae
Copy link

Thank you for the details @mschile

  • just to add the detail here, this time the return of the promise is not awaited even in Run mode
    • so not sure if it's still related to the experimentalInteractiveRunEvents
  • maybe related to something introduced in the fix of before:spec broken? #22360
    • or along the way with new features / other fixes

@alexniculae
Copy link

alexniculae commented Nov 11, 2022

Please note that, for my org, this is a blocking issue for upgrading Cypress to v10 or above

  • we are dependent on the before:spec to wait for the promise to be solved before moving forward
  • if not, our user assignation system is malfunctioning, causing most of the tests to have conflicts due to duplicate logins

Dur to this matter we are unable to update Cy from v9 to v10 or 11.

Could you please share an ETA for the fix?

Thank you,

Alex

@emilyrohrbough
Copy link
Member

@alexniculae Is this a fix you'd be will to contribute to unblock your org?

@alexniculae
Copy link

@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.

@emilyrohrbough
Copy link
Member

@alexniculae No problem!

@ioannisNoukakis
Copy link
Author

@emilyrohrbough If no one has started to fix this I'm willing to contribute

@emilyrohrbough
Copy link
Member

@ioannisNoukakis We would love your contribution!

@emilyrohrbough
Copy link
Member

@ioannisNoukakis Any update?

@ioannisNoukakis
Copy link
Author

@emilyrohrbough Yeah I thought I had the bandwidth to do this fix but I don't. Sorry

@emilyrohrbough
Copy link
Member

@ioannisNoukakis no worries! I'm going to pick this up then. Thanks for trying! We love getting contributions 😄

@alexniculae
Copy link

Hey @emilyrohrbough,

Curious if we have any updates on this one 🙂 Was this picked up as WIP, do we have a proposed release for a fix?

Thank you

@emilyrohrbough
Copy link
Member

@alexniculae I started to work on this and had to put it off for due to some refactoring required in the app for this to work correctly. Hoping to take some time soon to wrap this up.

@jhulme
Copy link

jhulme commented Mar 8, 2023

@emilyrohrbough - is there any movement expected on this issue in the near future at all?

@emilyrohrbough
Copy link
Member

emilyrohrbough commented Mar 8, 2023

@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 run mode, however, more work is needed to successfully implement in open mode. Specifically, it works in open mode 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's before:spec promise 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.

@emilyrohrbough
Copy link
Member

Actually! @mschile pointed out that the work for run and open mode could be broken out into two fixes because the open mode 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 run mode.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 14, 2023

Released in 12.8.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v12.8.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Mar 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants