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

Feature: Make clearing SessionStorage and LocalStorage between test runs configurable #2243

Closed
robbiedhickey opened this issue Mar 22, 2018 · 3 comments
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot.

Comments

@robbiedhickey
Copy link

Are you requesting a feature or reporting a bug?

A feature.

What is the current behavior?

#1590 added the behavior to TestCafe to automatically clear LocalStorage and SessionStorage in between test runs.

What is the desired behavior?

Provide a configuration point to disable this behavior.

Use Case

The application under test that I'm supporting stores its authentication token and related user data in SessionStorage. Clearing the session storage between each test run is causing us to have to re-run the login scenario in the beforeEach function for all of our fixtures.

We've wrapped the login behavior in a PageObject so it's not too invasive, but it makes the test runs longer than they need to be. Is there a recommended way to handle this scenario? I tried to implement the same concept using the documented Role function but ran into the same issue - with cleared SessionStorage forcing the application to redirect to the login screen.

@snowl
Copy link

snowl commented Mar 23, 2018

Check out #2142, I had the same issue.

@robbiedhickey
Copy link
Author

Yesterday I had hacked together a couple of ClientFunctions to persist the state between tests and tenuously got things working.

Oddly enough, after reading through #2142 it looks like the preserveUrl option is the secret sauce that ended up working for my use case. It looks like in addition to preserving the URL that was redirected to after login, it also preserves sessionStorage, which is exactly the behavior I was expecting!

Thanks @snowl!

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
STATE: Auto-locked An issue has been automatically locked by the Lock bot.
Projects
None yet
Development

No branches or pull requests

2 participants