Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/testing/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

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

## Pest Browser Testing

[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.

.
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.


```php
//tests/Browser/FilterFieldTest.php

$searchField = '[wire\:model\.live\.debounce\.700ms="search"]';

it('can filter by existing record')
->withVite() //enable Vite for this test
->visit('/examples/demo-dish')
->assertSee('Arkansas Possum Pie')
->fill($searchField, 'Bacalhau')
->assertDontSee('Arkansas Possum Pie')
->assertSee('Bacalhau com natas');
```

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.

## Liveware Testing

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:

### Testing Actions Buttons
Expand Down
Loading