-
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
async functions of tests can write the localStorage after it was cleared for the following test #1083
Comments
What you're describing is outlined in detail here: #686 It's a known issue of Cypress and the API's have to be expanded to account for it. There are other edge cases beyond just localStorage that can be introduced. To migitate this today you will have to write your tests in a way that each is isolated (by doing a visit before each) and not allowing state to build up in between tests. Looking at your example repo I can see that you are allowing state to be leaked between the tests by not starting at a fresh point. Some of our users do something like an Another way is to use the |
Sure we can find a workaround for our problem for now. After reading the related Ticket here my opinion: Tests running independently from each other should always be considered "best practice". |
Having the same issue in a real life app test here. |
Another likely reproducible example of this LocalStorage issue: |
In v12.0.0 (soon-to-be-released), we are introducing the concept of Test Isolation to prevent cases like this. There will be two modes of test isolation,
This will prevent DOM and browser state bleed over between tests. Closing this issue as done and tagging for the v12.0.0 release. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
Current behavior:
Even so Cypress clears the
localStorage
before each test older tests can still have unresolved async functions (for example returning API calls) that write into thelocalStorage
during the execution of the next test.Desired behavior:
testcases are killed completely so no code can be executed anymore.
How to reproduce:
see: Test Code (README.md)
Test code:
https://github.com/Aligertor/cypressTestLocalStorage
Additional Info / Our real world problem
In our real scenario JS Application potentially does API calls after be loaded into the browser the first time. We set some
cy.route
's to define the response of those calls, Therefore we have a set of commands defining different routes for different test cases.In some of our test cases we now have to wait for these calls to resolve because some handlers will write into localStorage.
Ideally we dont have to care about this.
If this is not possible at least there should be better support to use commands aka "be able to use an alias of an route no matter where it was defined" so people can take care of those timing issues by adding a
cy.wait
without guessing millisecondsThe text was updated successfully, but these errors were encountered: