Skip to content

Commit d1d7fd2

Browse files
add browser test exmaple
1 parent 3fa2323 commit d1d7fd2

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

docs/testing/index.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22

33
Create a test component inside the `tests` folder in your application, for example `tests/Feature/Livewire/UsersTableTest.php`
44

5+
## Pest Browser Testing
6+
7+
[Pest Browser Testing](https://pestphp.com/docs/browser-testing) allows you to simulate authentic user interactions within your application—including clicking elements, typing input, and selecting options in real time.
8+
9+
.
10+
The next example tests the [PowerGrid Demo](https://demo.livewire-powergrid.com/examples/demo-dish) component, ensuring that clicking and typing in the filter field will perform the search query and return the expected records.
11+
12+
13+
```php
14+
//tests/Browser/FilterFieldTest.php
15+
16+
$searchField = '[wire\:model\.live\.debounce\.700ms="search"]';
17+
18+
it('can filter by existing record')
19+
->withVite() //enable Vite for this test
20+
->visit('/examples/demo-dish')
21+
->assertSee('Arkansas Possum Pie')
22+
->fill($searchField, 'Bacalhau')
23+
->assertDontSee('Arkansas Possum Pie')
24+
->assertSee('Bacalhau com natas');
25+
```
26+
27+
Here, we guarantee the row "Arkansas Possum Pie" is visible when the page loads. Then, we simulate a click in the filter and typing the word "Bacalhau". As a result, we ensure that "Arkansas Possum Pie" is not visible anymore, while the row "Bacalhau com natas" is visible.
28+
29+
## Liveware Testing
30+
531
You should follow the same concept defined in the [livewire documentation](https://livewire.laravel.com/docs/testing), and then you will be able to use other native assertions in PowerGrid:
632

733
### Testing Actions Buttons

0 commit comments

Comments
 (0)