Livewire Plugin
Overview
The Livewire Plugin for Pest provides additional functions for testing your Livewire components.
Source code: github.com/pestphp/pest-plugin-livewire
Installation
Install the plugin using Composer:
composer require pestphp/pest-plugin-livewire --dev
Available functions
livewire()
You may use the livewire
function to test your Livewire components:
use function Pest\Livewire\livewire;
it('can be incremented', function () {
livewire(Counter::class)
->call('increment')
->assertSee(1);
// Same as:
$this->livewire(Counter::class)
->call('increment')
->assertSee(1);
});
it('can be decremented', function () {
livewire(Counter::class)
->call('decrement')
->assertSee(-1);
// Same as:
$this->livewire(Counter::class)
->call('decrement')
->assertSee(-1);
});
Of course, the method livewire()
can be equally used in your higher order tests:
it('can be incremented')
->livewire(Counter::class)
->call('increment')
->assertSee(1);
it('can be decremented')
->livewire(Counter::class)
->call('decrement')
->assertSee(-1);
Finally, for the full list of available Livewire methods, please refer to the Livewire documentation.
Next section: Faker →