Skip to content

Commit 81c0362

Browse files
authored
Merge pull request #347 from negoziator/feature/make-hostname-configurable-docs
Docs for: Allow overriding hostname
2 parents 0e5adb6 + 16d9cd5 commit 81c0362

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

browser-testing.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ You may wish to override the User Agent of the browser for all of your tests, yo
196196
pest()->browser()->userAgent('CustomUserAgent');
197197
```
198198

199+
### Configuring Host
200+
201+
By default, the server will bind to `127.0.0.1` for all browser tests.
202+
203+
You may wish to override the host for subdomain applications. You can configure this in the `Pest.php` configuration file:
204+
205+
```php
206+
pest()->browser()->withHost('some-subdomain.localhost');
207+
```
208+
199209
### Geolocation
200210

201211
Sometimes, you need to define where the browser believes it is physically on the earth. This method takes a latitude and longitude and will set the `geolocation` permission in the browser and then make the coordinates available via Javascript's getCurrentPosition API:
@@ -234,6 +244,16 @@ $page = visit('/')->withUserAgent('Googlebot');
234244
$page->assertSee('Welcome, bot!');
235245
```
236246

247+
### Configuring Host
248+
249+
You can set the host for your test server using the `withHost` method. This is useful for testing subdomains or where different hosts serve different content.
250+
251+
```php
252+
$page = visit('/dashboard')->withHost('some-subdomain.localhost');
253+
254+
$page->assertSee('Welcome to Some Subdomain');
255+
```
256+
237257
## Table of Contents
238258

239259
### Available Assertions

0 commit comments

Comments
 (0)