From 23608159050d0322a8f15c865686b6382c3d5ed3 Mon Sep 17 00:00:00 2001 From: Lars Schou Date: Fri, 9 Jan 2026 21:34:46 +0100 Subject: [PATCH] Make ->withHost available when using visit(..) --- src/Api/PendingAwaitablePage.php | 10 ++++++++++ tests/Browser/Visit/SubdomainTest.php | 6 ++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Api/PendingAwaitablePage.php b/src/Api/PendingAwaitablePage.php index f8aad8d9..77deb534 100644 --- a/src/Api/PendingAwaitablePage.php +++ b/src/Api/PendingAwaitablePage.php @@ -118,6 +118,16 @@ public function withUserAgent(string $userAgent): self ]); } + /** + * Sets the host for the server. + */ + public function withHost(string $host): self + { + Playwright::setHost($host); + + return new self($this->browserType, $this->device, $this->url, $this->options); + } + /** * Sets the timezone for the page. */ diff --git a/tests/Browser/Visit/SubdomainTest.php b/tests/Browser/Visit/SubdomainTest.php index 702157b6..59e0e8dc 100644 --- a/tests/Browser/Visit/SubdomainTest.php +++ b/tests/Browser/Visit/SubdomainTest.php @@ -15,9 +15,8 @@ '); - pest()->browser()->withHost('app.localhost'); - visit('/app-test') + ->withHost('app.localhost') ->assertSee('Welcome to NON Subdomain') ->assertSeeIn('#content', 'This is the non subdomain content') ->assertTitle('Non Subdomain'); @@ -33,9 +32,8 @@ ]); }); - pest()->browser()->withHost('api.localhost'); - visit('/api/health') + ->withHost('api.localhost') ->assertSee('"status":"ok"') ->assertSee('"subdomain":"api"') ->assertSee('"host":"api.localhost"');