← All notes

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

Sources

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

Permanent ID: iil:note:5fb1j7xj

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.},
}

Markdown

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.

All artifact files (JSON index)

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.