Code in hooks and test are rerun when changing to a different superdomain
See original GitHub issueCurrent behavior:
When running my spec file, I noticed that some code in the before
hook (not beforeEach
) is being run before each of my three test cases, causing my checks to fail. Want to remark that I am using different superdomains for every test, I don’t see this when I run all the tests with the same superdomain.
Desired behavior:
Code in the before
hook only runs once, before all the tests, no matter if using different superdomains.
Steps to reproduce:
I explain my setup. My spec file consists of:
- before()
- after()
- it() //superdomain 1
- it() //superdomain 2 using an iframe
- it() //superdomain 1
As I am using different superdomains, the only way that I’ve read to do it is visiting the different domains in different tests (https://docs.cypress.io/guides/guides/web-security.html#One-Superdomain-per-Test)
I’ve also set "chromeWebSecurity": false
Within the before hook I run several requests to some endpoints as a way to get some data that I will use through the tests; Get it once, and use it across the three it().
I’ve also set a console.log('This only happens in the beforeHook: ' + var)
to see what’s the value of my variable, and this is what I see in the run:
-
Running the first it()
-
Second it()
-
Third it()
After every it()
the console gets cleared, which is fine, but I don’t expect to see the log again during the second and the third tests, as this is supposed to run only once. Notice how the variable gets an increment for each loop, as I would expect had I done it in a beforeEach
hook.
In the left side of the window every seems fine as there is no command logging for the before
hook when running the second and third tests, but the console.log
reveals that.
Versions
- Cypress version: 3.0.1
- Browser: Chrome 66
- OS: Ubuntu Linux 16.04 LTS
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (4 by maintainers)
Top GitHub Comments
Sorry, we accidentally merged the PR above prematurely. This is still in the review stage. We will close this issue and comment when this issue is merged for the next upcoming release.
Thank you so much for the thorough bug report! Indeed the behavior does appear to be different when visiting different superdomains.
Cypress version 3.0.1, no configuration, support files, or plugins.
My recreation of the issue:
Preserved console warnings for subdomain tests
Preserved console warnings for superdomain tests