-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Code in before hooks are rerun when navigating to new superdomain #17164
Comments
The describe('demonstrate multiple runs of the before() function in a single test script', () => {
before(() => {
console.log(">ran before all")
})
it("superdomain 1", () => {
cy.visit("https://ag.montana.edu/departments/")
})
it("superdomain 2", () => {
cy.visit("http://animalrange.montana.edu/directory/faculty/index.html")
})
}) |
Thank you for the explanation, that helps me understand why it would happen. |
Is this likely to be fixed? We've experienced the same problem. |
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. |
See #17940 |
Current behavior
In a single test script, with a single describe that contains a before(), beforeEach(), and beforeAfter(), the before() method can be invoked multiple times. In this example before() is being invoked before the first test, then again on a test that visits a page with an xhr request loading its main content, then again on the test following that one. Accessing the DOM via cy.get() is required to observe this behavior. Another observed effect is that the console is getting cleared. I'm not relying on a full console log for anything but on the other hand I have no desire for it to be cleared.
It reaches this point
Then seems to hiccup
Then the GUI seems to get back on track but you look through the console it got cleared just before the Microbiology and Immunology test and re-ran the before() function.
Desired behavior
Two outcomes would be better than the current behavior.
Test code to reproduce
Two tests in the middle of this script focus on the page in question. The currently skipped test accesses the returned xhr response directly and results in the desired behavior. The currently not-skipped test demonstrates the undesired behavior. This test accesses a page which makes a call for an xhr resource. The Cypress gui kind of blinks, the console gets cleared, and the before() function is run again but Cypress continues with the test in question. After finishing with the test of a page with the xhr resource, the Cypress gui kind of blinks again, the console gets cleared a second time, and the before() function is run again. No error is logged that I can tell. The GUI log on the left of the test browser appears to indicate that everything ran ok.
https://github.com/anmeeks-vt-edu/cypress-test-tiny/blob/master/cypress/integration/spec.js
Versions
All versions of Cypress used to run this:
7.6.0
6.8.0
The text was updated successfully, but these errors were encountered: