storageState reuses saved authenticated browser state across tests
Answer: Playwright executes tests in isolated environments called browser contexts. Tests can load existing authenticated state, so they do not have to authenticate in every test, which also speeds up the run. An authentication routine can produce authenticated browser state and save it to a file. Later on, tests will reuse this state and start already authenticated.
Recommended shared-account setup
Create a setup project that signs in and then calls page.context().storageState({ path: authFile }). Add a setup project in the config and declare it as a dependency of the testing projects. That setup project authenticates first. Each testing project should then take the authenticated state via storageState.
This is the recommended approach when tests can share one account and do not change server-side state in ways that would collide. The state file can hold sensitive cookies and headers, so do not commit it.
See also
Claims
- id: C1 claim: Tests can load existing authenticated state instead of signing in every time. source: S1 evidence: "Tests can load existing authenticated state"
- id: C2 claim: Later tests reuse the saved state and start already authenticated. source: S1 evidence: "tests will reuse this state and start already authenticated"
- id: C3 claim: storageState on the browser context writes the authenticated state to a file. source: S2 evidence: "await page.context().storageState({ path: authFile })"
- id: C4 claim: Testing projects should use the saved state as storageState. source: S2 evidence: "use the authenticated state as
storageState"
Sources
- [S1] Authentication. Playwright docs. https://playwright.dev/docs/auth . License: Apache-2.0. Accessed 2026-11-17.
- [S2] auth.md (Playwright source docs). microsoft/playwright (GitHub). https://github.com/microsoft/playwright/blob/main/docs/src/auth.md . License: Apache-2.0. Accessed 2026-11-17.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Playwright docs, Authentication, Apache-2.0 (https://raw.githubusercontent.com/microsoft/playwright/main/LICENSE). Copyright (c) Microsoft Corporation; microsoft/playwright (GitHub), auth.md (Playwright source docs), Apache-2.0 (https://raw.githubusercontent.com/microsoft/playwright/main/LICENSE). Copyright (c) Microsoft Corporation. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Playwright docs, Authentication, Apache-2.0 (https://raw.githubusercontent.com/microsoft/playwright/main/LICENSE). Copyright (c) Microsoft Corporation; microsoft/playwright (GitHub), auth.md (Playwright source docs), Apache-2.0 (https://raw.githubusercontent.com/microsoft/playwright/main/LICENSE). Copyright (c) Microsoft Corporation.
Cite this
iinventedlight. 2026. "storageState reuses saved authenticated browser state across tests." iinventedlight Library, iil:note:5fb1j7xj, version of 2026-11-17. https://iinventedlight.com/library/notes/playwright-storage-state/. License: CC-BY-4.0.
@misc{iil_note_5fb1j7xj,
author = {{iinventedlight}},
title = {{storageState reuses saved authenticated browser state across tests}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-17},
url = {https://iinventedlight.com/library/notes/playwright-storage-state/},
note = {Permanent ID iil:note:5fb1j7xj. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- playwright-storage-state.table.json (table; CC-BY-4.0)
- playwright-storage-state.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/playwright-storage-state.md.