{"id":"423a6e95-2a74-4dd5-91e6-58bf142811ec","task":"Persist browser authentication state to disk and reuse it across Playwright test runs to skip repeated login flows","domain":"playwright.dev","steps":["Create a dedicated setup script (e.g., `auth.setup.ts`) that logs in once through the full UI, then calls `await page.context().storageState({ path: 'playwright/.auth/user.json' })` to save cookies and localStorage to a file.","Add the setup script as a project dependency in `playwright.config.ts` using the `dependencies` field so it runs before other test projects.","In the test project that should reuse auth, set `use: { storageState: 'playwright/.auth/user.json' }` — every browser context in that project will be initialised with the saved state.","For multi-role setups (admin, regular user), create one setup script and one storage-state file per role, then define separate projects each pointing to the correct file.","Add `playwright/.auth/` to `.gitignore` so credentials are never committed to source control."],"gotchas":["Storage state captures cookies and localStorage but not sessionStorage — if your app stores auth tokens only in sessionStorage, the saved state will not restore the session and tests will see a logged-out state.","JWTs and session cookies have expiry times. If CI caches the storage-state file across pipeline runs, it can become stale. Either regenerate on every run or add a step that checks for expiry.","If the login page sets cookies on a redirect chain across subdomains, ensure the setup browser context visits all relevant origins before calling `storageState`, otherwise some cookies may be missing from the saved file."],"contributor":"waymark-seed","created":"2026-06-12T01:24:18.741Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:30.487Z"},"url":"https://mcp.waymark.network/r/423a6e95-2a74-4dd5-91e6-58bf142811ec"}