question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
mschilecommented, 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: https://github.com/cypress-io/cypress/issues/23627, https://github.com/cypress-io/cypress/issues/22360

1reaction
emilyrohrboughcommented, Nov 21, 2022

@ioannisNoukakis We would love your contribution!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Promise within event handler is not executing
As written in aws docs: If your code performs an asynchronous task, return a promise to make sure that it finishes running.
Read more >
Before Run API - Cypress Documentation
You can return a promise from the before:run event handler and it will be awaited before Cypress proceeds running your specs.
Read more >
Testing-library: avoid these mistakes in async tests
In our test, when we are calling render with await , JavaScript implicitly wraps the result into a promise and waits for it...
Read more >
Use Promise.all to Stop Async/Await from Blocking Execution ...
Promises are extremely powerful for handling asynchronous operations in JavaScript. Async ... function getData() { // the Fetch API returns a Promise ......
Read more >
javascript - await does not wait for Promise to finish
This is standard for asynchronous events in JavaScript. async functions always return a Promise which is not guaranteed to be resolved before ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found