Skip to content

Commit 4af056e

Browse files
committed
Adjusts browser documentation
1 parent 8642633 commit 4af056e

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

browser-testing.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ We recommend running tests in parallel using the `--parallel` option to speed up
7373
./vendor/bin/pest --parallel
7474
```
7575

76+
For debugging purposes, you can run the tests in a headed mode and pause the execution at the end of the failed test run:
77+
78+
```bash
79+
./vendor/bin/pest --debug
80+
```
81+
7682
### Navigation
7783

7884
The `visit()` method is used to navigate to a specific URL in your browser test. It provides various methods to interact with the page:
@@ -94,6 +100,13 @@ By default, the `visit()` method uses Chrome as the browser. However, if you wan
94100
./vendor/bin/pest --browser=safari
95101
```
96102

103+
If you wish to use a different browser by default without specifying it in the command line, you can set it in your `Pest.php` configuration file:
104+
105+
```php
106+
pest()->browser()->inFirefox();
107+
pest()->browser()->inSafari();
108+
```
109+
97110
### Using Other Devices
98111

99112
The `visit()` method uses a desktop viewport. However, you can specify a mobile viewport using the `onMobile()` method. For example:
@@ -164,6 +177,14 @@ $page->click('#submit-button');
164177
// etc...
165178
```
166179

180+
### Configuring Timeouts
181+
182+
Sometimes, elements may take time to appear on the page. By default, Pest waits for `5` seconds before timing out. You can configure the default timeout for browser tests in your `Pest.php` configuration file:
183+
184+
```php
185+
pest()->browser()->timeout(10);
186+
```
187+
167188
## Table of Contents
168189

169190
### Available Assertions
@@ -1013,7 +1034,13 @@ $page->waitForKey(); // Useful for debugging
10131034
## Debugging tests
10141035

10151036
<a name="debug"></a>
1016-
Sometimes you may want to debug your browser tests. Pest provides a convenient way to do this by using the `debug()` method, which focus Pest only on the current test and allows you to inspect the page state:
1037+
Sometimes you may want to debug your browser tests. Pest provides a convenient way to do this by using the `--debug` option, which makes pest to open the browser window and pause the execution of the test when it fails. You can then inspect the page and see what went wrong.
1038+
1039+
```bash
1040+
./vendor/bin/pest --debug
1041+
```
1042+
1043+
Optionally, you can also use the `debug()` method in your test to pause the execution and open the browser window:
10171044

10181045
```php
10191046
$page->debug();
@@ -1042,6 +1069,12 @@ After you can run your tests with the `--headed` option to open the browser wind
10421069
./vendor/bin/pest --headed
10431070
```
10441071

1072+
If you wish to run the tests in a headed mode by default, you can set it in your `Pest.php` configuration file:
1073+
1074+
```php
1075+
pest()->browser()->headed();
1076+
```
1077+
10451078
## Continuous Integration
10461079

10471080
You may refer to Pest's [Continuous Integration](https://pestphp.com/docs/continuous-integration) documentation for more information on how to run your browser tests in a CI environment.

0 commit comments

Comments
 (0)