Skip to content

feat: add saving storage states#207

Open
veljkho wants to merge 1 commit intopestphp:4.xfrom
veljkho:add/feature/storage-state
Open

feat: add saving storage states#207
veljkho wants to merge 1 commit intopestphp:4.xfrom
veljkho:add/feature/storage-state

Conversation

@veljkho
Copy link
Copy Markdown

@veljkho veljkho commented Apr 6, 2026

Adds support for Playwright's storage state feature, allowing tests to save and restore browser context state (cookies and localStorage). The primary use case is skipping repetitive login flows across tests.

After a login flow, save the authenticated state:

// tests/Browser/Auth/LoginTest.php
test('store authenticated state', function (): void {
    visit('/login')
        ->fill('#email', 'admin@example.com')
        ->fill('#password', 'secret')
        ->click('Login')
        ->assertUrlContains('/dashboard')
        ->saveStorageState('admin');
});

All other tests just reuse it:

// tests/Browser/DashboardTest.php
test('can see dashboard', function (): void {
    visit('/dashboard')
        ->withStorageState('admin')
        ->assertSee('Welcome back');
});

test('can see settings', function (): void {
    visit('/settings')
        ->withStorageState('admin')
        ->assertSee('Account Settings');
});

This is a nice feature in Playwright, would be great to see it also in Pest.

This adds feature to save browser's storage state just like in Playwright
@veljkho veljkho changed the title Add feature saving storage states feat: add saving storage states Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant