Skip to main content
Q&A

How do you persist authentication state across Playwright tests without logging in every time?

Ajitesh Mohanta
Ajitesh MohantaAmbassador
Jun 3, 2026 1,313 4
Our Playwright suite has 200+ tests and login takes 3–4 seconds each time. Running everything serially we're losing ~15 minutes just to auth. I know about `storageState` but I'm not sure of the right pattern when: 1. Some tests need a regular user, others need an admin 2. Tokens expire after 30 minutes (our staging env is aggressive about this) 3. We run tests in parallel across 4 workers Do you re-use a single storage state file per role, regenerate per worker, or something else? Would love to see your `playwright.config.ts` setup if you've solved this cleanly.

No accepted answer yet

If a comment solves your problem, the author can mark it as the accepted answer.

4 Comments

Sort:
Gaurav Khurana
Jun 27, 2026
Create Auth state with eachusernamealongwithtime.json
Before running a test validate if time is greater than 30 min religion and generate Auth state and continue this way you need not to login before 30 minutes. We did this
Ishan Dev Shukl

Indeed, that's a great idea!

Vishal Sharma

Can we not use session storage here ??

Dhrumil Soni

storageState feature: https://playwright.dev/docs/auth

Join the discussion

Sign in to join the discussion

Sign in
How do you persist authentication state across Playwright tests without logging in every time? — QABash Community | QABash