Skip to content

Conversation

@negoziator
Copy link
Contributor

Make withHost chainable directly on visit()

Currently withHost is not chainable directly on visit()

Added missing function withHost(..) in PendingAwaitablePage

Usage

Single visit withHost

visit('/dashboard')
    ->withHost('app.localhost')
    ->assertSee('Content from app.localhost');

Visit withHost takes precedence over global host

pest()->browser()->withHost('app.localhost');

visit('/dashboard')
    ->withHost('test.domain')
    ->assertSee('Content from test.domain');

Visit without withHost() falls back to the global host

pest()->browser()->withHost('app.localhost');

visit('/dashboard')
    ->withHost('test.domain') // <-- Only overrides host in the visit
    ->assertSee('Content from test.domain');

visit('/dashboard')
    ->assertSee('Content from app.localhost'); // <--- Falls back to global host

@negoziator negoziator changed the title Make ->withHost available when using visit(..). Do not override globa… Make ->withHost available when using visit(..) Jan 10, 2026
@nunomaduro nunomaduro merged commit 72cb88b into pestphp:4.x Jan 11, 2026
2 of 3 checks passed
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.

2 participants