Skip to content

feat(cli): auth flows via Playwright storage state #81

Description

@nucliweb

Goal

Allow measuring pages that require authentication by passing a Playwright storage state file (cookies + localStorage), using Playwright's own native format.

Usage

# Step 1 — capture auth state with Playwright codegen
npx playwright codegen --save-storage=auth.json https://example.com/login

# Step 2 — measure an authenticated page
npx webperf-snippets https://example.com/dashboard --storage-state auth.json

Implementation

One-line change in cli/src/runner.js:

// before
const context = await browser.newContext({ viewport });

// after
const context = await browser.newContext({ viewport, storageState: opts.storageState });

Files

  • cli/src/runner.js — pass storageState to newContext()
  • cli/src/bin.js — expose --storage-state <path> flag

Acceptance criteria

  • --storage-state <path> restores session before navigation
  • Fails with a clear error if the path does not exist
  • Documented in README with the full two-step workflow

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCLI packageenhancementNew feature or requestv0.4Milestone v0.4

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions