playwright-auth

Automate Playwright authentication flows with storage state persistence.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/leonardoacosta/central-claude --skill playwright-auth-leonardoacosta
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-auth
Source: https://github.com/leonardoacosta/central-claude/tree/main/skills/playwright-auth
Command: npx skills add https://github.com/leonardoacosta/central-claude --skill playwright-auth-leonardoacosta

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Ensures consistent, testable authentication flows for Playwright end-to-end suites so tests don't waste time on flaky or duplicated login steps and teams can reuse authenticated contexts across tests and CI runs.

Core Features & Use Cases

  • Auth Flow Contract: Defines required inputs (credentials, login URL, selectors) and outputs (authenticated Page and optional persisted storage state) for deterministic login flows.
  • Integration Patterns: Describes when to use Page Object Model for complex login pages and when to use fixture-based pre-authenticated pages for multi-role scenarios.
  • Storage State Management: Recommends saving and restoring storage state in a gitignored .auth directory, regenerating on CI, and one file per role for speed.
  • Credential Sources & Safety: Advises using environment variables with safe fallbacks for local dev and never committing real credentials.
  • Anti-Patterns & Best Practices: Lists common mistakes to avoid, such as logging in every test, using brittle selectors, or storing auth state in repo.

Quick Start

Use the playwright-auth guidance to implement a Playwright login flow that authenticates an admin user and saves storage state for reuse.

Frequently Asked Questions about playwright-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I persist login state in Playwright to skip authentication across multiple tests?

Playwright storage state persistence saves authenticated cookies and localStorage to a file, allowing subsequent tests to bypass login. You reuse this saved state to generate pre-authenticated browser contexts, eliminating repetitive login steps across your test suite.

What is the best way to manage Playwright authentication for multiple user roles in E2E testing?

Managing multi-role Playwright authentication involves using fixture-based pre-authenticated pages and saving a separate storage state file per role. This generates isolated authenticated contexts for each user type, ensuring deterministic E2E test execution.

Can I use environment variables for Playwright test credentials without committing them to my repository?

You can use environment variables for Playwright test credentials with safe fallbacks for local development. Never commit real credentials to your repository; instead, save and restore storage state in a gitignored .auth directory and regenerate it on CI.

When should I use the Page Object Model vs fixtures for Playwright login automation?

Use the Page Object Model for Playwright login automation when handling complex login pages with dynamic form selectors. Use fixture-based pre-authenticated pages when you need to reuse isolated authenticated contexts across multiple tests and multi-role scenarios.

Why does my Playwright authentication fail when running E2E tests in CI?

Playwright authentication fails in CI due to brittle form selectors or missing credential sources. Ensure deterministic login flows by defining exact form selectors, using environment variables for credentials, and regenerating storage state files directly on the CI server.