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

Before/beforeEach hooks run multiple times when running all tests is invoked from Cypress GUI #717

Closed
ghost opened this issue May 19, 2022 · 3 comments

Comments

@ghost
Copy link

ghost commented May 19, 2022

Current behavior

When running all spec files is invoked from GUI using the "Run ## integrations tests" button, then all beforeEach and before hooks run as many times as there are spec files before each and before all tests.

image

This is the hook in question - it resides in a common steps file
image

This is what I see when the test runs - it slows the whole test suite by a lot.
image

The same does not happen when tests are invoked in headless mode - then all hooks run correctly.

Desired behavior

before hooks should only run once per the whole test suite (before each spec file would also be acceptable)
beforeEach hooks should only run once before each scenario.

Test code to reproduce

I will provide one when I have more time to work on this

Versions

  • Cypress version: 9.3.5
  • Preprocessor version: 9.2.1
  • Node version: 16.9.1
@ghost ghost changed the title Before/After hooks run multiple times when "Run x" Before/beforeEach hooks run multiple times when running all tests is invoked from Cypress GUI May 19, 2022
@badeball
Copy link
Owner

This is a problem with Cypress, is present with preprocessor or not, and reported EG. here.

@ghost
Copy link
Author

ghost commented May 19, 2022

Ah, I see. Would it be difficult to work around the issue by wrapping each feature in a describe block, as pointed out by this comment? I understand it might be undesirable to "fix" underlying problems by introducing workarounds, but I guess this one might be warranted.

@badeball
Copy link
Owner

The 10-release is scheduled for 1st of june and appears to be removing "Run all specs" altogether, ref:

The “Run all specs” and “Run filtered specs” functionality have been removed.

Hence, this is not something I will be focusing on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant