cypress
cypress copied to clipboard
before hook only executed once in open mode with `experimentalRunAllSpecs`
Current behavior
When adding a before
hook in the support file, it is only executed once at the beginning of the first test that gets executed.
Desired behavior
As stated in the documentation https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests#Support-file the support files (and so the before
) hook should be executed before any suite/file.
Test code to reproduce
Add a simple before
hook into any support file in a project that has at least two suite files.
E.g.
before(() => {
cy.log('I am a BEFORE support hook');
})
Run all tests and look for the output.
Cypress Version
12.7.0
Node version
18
Operating System
Ubuntu 20
Debug Logs
No response
Other
No response
Hi @chbiel , thanks for opening an issue. Are you seeing this behavior when running your tests using cypress run
, or using cypress open
with the experimentalRunAllSpecs
flag enabled?
I only checked it with cypress open
and yes, we have experimentalRunAllSpecs
enabled.
It happens there also when running single sub folders.
I will try to check later the day, if it also happens in cypress run
EDIT:
checked cypress run
. In all combinations of testIsolation
and experimentalRunAllSpecs
the before
hook got executed at the beginning of each file. So it seems to be limited to cypress open
.
A small recommendation: I think the documentation should somewhere define what a suite
(from the context I understand that it is a describe
block). Do you also have a name for the file
that can contain several suites
?
If you need more info, I am happy to help :)
@chbiel Thanks for the info. Unfortunately this is a known issue with experimentalRunAllSpecs
mode, and one of the reasons it is still an experimental feature. It is on our roadmap of issues to get resolved prior to enabling that feature by default.
To your question around "Suite" wording, we typically use these terms but every org has their own semantics so you'll likely see other vocabulary across different sites/projects:
Spec -> File
Suite ->describe
block
Test -> it
block
This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.
This issue has been closed due to inactivity.