From e10a75a09043c6768c1aa7812eaa0eb43a945925 Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 7 Sep 2025 18:29:39 +0100 Subject: [PATCH 1/6] Update browser-testing.md --- browser-testing.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/browser-testing.md b/browser-testing.md index 3720d8c..fb1faf2 100644 --- a/browser-testing.md +++ b/browser-testing.md @@ -186,6 +186,44 @@ Sometimes, elements may take time to appear on the page. By default, Pest waits pest()->browser()->timeout(10); ``` +### Configuring User Agent + +You may want to set the user agent of the browser for all of your tests, you can configure this in the `Pest.php` configuration file: + +```php +pest()->browser()->userAgent('CustomUserAgent'); +``` + +### Per-Test Overrides +In addition to configuring defaults globally, you can override settings per test using the following methods: + +#### Setting Locale + +```php +it('shows the page in French', function () { + $page = visit('/')->withLocale('fr-FR'); + + $page->assertSee('Bienvenue'); +}); +``` +#### Setting Timezone +```php +it('visits with user agent', function () { + $page = visit('/')->withUserAgent('Googlebot'); + + $page->assertSee('Welcome, bot!'); +}); +``` + +#### Setting UserAgent +```php +it('shows New York time', function () { + $page = visit('/')->withTimezone('America/New_York'); + + $page->assertSee('EST'); +}); +``` + ## Table of Contents ### Available Assertions From f878ffe49ef8866811ecdf6c6f31b9e7bf0f11b4 Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 7 Sep 2025 18:30:24 +0100 Subject: [PATCH 2/6] op --- browser-testing.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/browser-testing.md b/browser-testing.md index fb1faf2..6a0c460 100644 --- a/browser-testing.md +++ b/browser-testing.md @@ -186,14 +186,6 @@ Sometimes, elements may take time to appear on the page. By default, Pest waits pest()->browser()->timeout(10); ``` -### Configuring User Agent - -You may want to set the user agent of the browser for all of your tests, you can configure this in the `Pest.php` configuration file: - -```php -pest()->browser()->userAgent('CustomUserAgent'); -``` - ### Per-Test Overrides In addition to configuring defaults globally, you can override settings per test using the following methods: From 6e6342740ae16014a4318bb37bbd358d71251a77 Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 7 Sep 2025 18:34:35 +0100 Subject: [PATCH 3/6] space out --- browser-testing.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/browser-testing.md b/browser-testing.md index 6a0c460..9f540d8 100644 --- a/browser-testing.md +++ b/browser-testing.md @@ -187,6 +187,7 @@ pest()->browser()->timeout(10); ``` ### Per-Test Overrides + In addition to configuring defaults globally, you can override settings per test using the following methods: #### Setting Locale @@ -199,6 +200,7 @@ it('shows the page in French', function () { }); ``` #### Setting Timezone + ```php it('visits with user agent', function () { $page = visit('/')->withUserAgent('Googlebot'); @@ -208,6 +210,7 @@ it('visits with user agent', function () { ``` #### Setting UserAgent + ```php it('shows New York time', function () { $page = visit('/')->withTimezone('America/New_York'); From 8fd7be110f30b68a35554b54abc8bc05f81b1670 Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 7 Sep 2025 18:35:35 +0100 Subject: [PATCH 4/6] just page --- browser-testing.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/browser-testing.md b/browser-testing.md index 9f540d8..2ad13fd 100644 --- a/browser-testing.md +++ b/browser-testing.md @@ -193,30 +193,24 @@ In addition to configuring defaults globally, you can override settings per test #### Setting Locale ```php -it('shows the page in French', function () { - $page = visit('/')->withLocale('fr-FR'); +$page = visit('/')->withLocale('fr-FR'); - $page->assertSee('Bienvenue'); -}); +$page->assertSee('Bienvenue'); ``` #### Setting Timezone ```php -it('visits with user agent', function () { - $page = visit('/')->withUserAgent('Googlebot'); +$page = visit('/')->withUserAgent('Googlebot'); - $page->assertSee('Welcome, bot!'); -}); +$page->assertSee('Welcome, bot!'); ``` #### Setting UserAgent ```php -it('shows New York time', function () { - $page = visit('/')->withTimezone('America/New_York'); +$page = visit('/')->withTimezone('America/New_York'); - $page->assertSee('EST'); -}); +$page->assertSee('EST'); ``` ## Table of Contents From 53209008cfcc615148c22a31417eb9da255e027b Mon Sep 17 00:00:00 2001 From: Jack Date: Sun, 7 Sep 2025 18:36:48 +0100 Subject: [PATCH 5/6] Update browser-testing.md --- browser-testing.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/browser-testing.md b/browser-testing.md index 2ad13fd..47965fd 100644 --- a/browser-testing.md +++ b/browser-testing.md @@ -200,17 +200,17 @@ $page->assertSee('Bienvenue'); #### Setting Timezone ```php -$page = visit('/')->withUserAgent('Googlebot'); +$page = visit('/')->withTimezone('America/New_York'); -$page->assertSee('Welcome, bot!'); +$page->assertSee('EST'); ``` #### Setting UserAgent ```php -$page = visit('/')->withTimezone('America/New_York'); +$page = visit('/')->withUserAgent('Googlebot'); -$page->assertSee('EST'); +$page->assertSee('Welcome, bot!'); ``` ## Table of Contents From 3833f3a06f4accc41999d94f7e033fbeb135ddaa Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Wed, 10 Sep 2025 11:22:07 +0100 Subject: [PATCH 6/6] Update browser-testing.md --- browser-testing.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/browser-testing.md b/browser-testing.md index 47965fd..224736e 100644 --- a/browser-testing.md +++ b/browser-testing.md @@ -186,18 +186,18 @@ Sometimes, elements may take time to appear on the page. By default, Pest waits pest()->browser()->timeout(10); ``` -### Per-Test Overrides +### Configuring Locale -In addition to configuring defaults globally, you can override settings per test using the following methods: - -#### Setting Locale +You can set the locale for your test requests using the `withLocale` method. This is particularly useful for testing multilingual applications. ```php $page = visit('/')->withLocale('fr-FR'); $page->assertSee('Bienvenue'); ``` -#### Setting Timezone +### Configuring Timezone + +You can set the timezone for your test requests using the `withTimezone` method. This is useful for testing date and time displays in different time zones. ```php $page = visit('/')->withTimezone('America/New_York'); @@ -205,7 +205,9 @@ $page = visit('/')->withTimezone('America/New_York'); $page->assertSee('EST'); ``` -#### Setting UserAgent +### Configuring UserAgent + +You can set the User-Agent header for your test requests using the `withUserAgent` method. This is useful for testing how your application responds to different types of clients, such as mobile browsers or bots. ```php $page = visit('/')->withUserAgent('Googlebot');