Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Livewire

Testing Livewire v4 with Pest v4

Browser-based testing for Livewire components.

1 February 20261 min readLivewireاقرأ بالعربية

On this page

  1. Setup
  2. Component Test

Livewire v4 integrates with Pest v4 for real browser-based testing.

Setup

bash
composer require pestphp/pest --dev
php artisan pest:install

Component Test

php
it('increments the counter', function () {
    Livewire::test(Counter::class)
        ->assertSee('Count: 0')
        ->call('increment')
        ->assertSee('Count: 1');
});

it('validates input', function () {
    Livewire::test(CreatePost::class)
        ->set('title', '')
        ->call('save')
        ->assertHasErrors(['title' => 'required']);
});
All articles

Keep reading

  • Authorization in Livewire v4 Components1 February 20261 min read
  • Blaze Pre-Compiler: Massive Performance Gains in Livewire v41 February 20261 min read
  • Building a Bookmark Feature with Livewire v41 February 20261 min read