[Question] Update storageState to refresh token
See original GitHub issueI’m using Keycloak with a 30min refresh token. My test suite is longer than that and promptly at 30min it fails. I’m following the multiple sign-in roles pattern to generate two json files in my global-setup. Once I discovered the issue I assumed I needed to simply refresh my json files. So I created a method to do that in my utilities:
async saveStorageState(file = 'storageState.json') {
await this.page.context().storageState({ path: file })
}
I called it in several of my test cases but my tests still fail at exactly 30min. Am I updating the storageState.json correct? Can this be updated outside of the global-setup?
Issue Analytics
- State:
- Created a year ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How do I update my access token with a refresh token in msal?
MSAL takes care of refresh token for you. What you should do is always ask a token from MSAL before using one. If...
Read more >How to Handle Authentication in E2E Testing with Playwright
Let's start with the requirements first and answer the question, ... For instance, in our case, the access token was valid for a...
Read more >Understanding Refresh Tokens - Auth0
Learn about refresh tokens and the role they serve in the authorization ... To solve this problem, OAuth 2.0 introduced an artifact called...
Read more >Authentication | Playwright - CukeTest
Web apps use cookie-based or token-based authentication, where authenticated state is stored as cookies or in local storage. Playwright provides browserContext.
Read more >Update token lifetime - Microsoft Q&A
I have a SPA application, which authenticates the login with the azure ad, i get access token that expires in 60 minutes... How...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I was unable to get the storageState thing to work so I switched to fixtures and came up with the following:
@aslushnikov Does playwright cache or otherwise use the same storageState file given in the global-setup or does it re-read it each time it creates a new browser context?