This package adds some nice new Livewire assertions which I was missing while testing my applications using Livewire. If you want to know more about WHY I needed them, check out my blog article.
You can install the package via composer:
composer require christophrumpel/missing-livewire-assertions
The new assertions get added automatically, so you can use it immediately.
Livewire::test(FeedbackForm::class)
->assertPropertyWired('email');
It looks for a string like wire:model="email"
in your components's view file. It also detects variations like wire:model.defer="email"
, wire:model.lazy="email"
, wire:model.debounce="email"
, wire:model.lazy.10s="email"
or wire:model.debounce.500ms="email"
.
Livewire::test(FeedbackForm::class)
->assertMethodWired('submit');
Livewire::test(FeedbackForm::class)
->assertMethodWiredToForm('upload');
It looks for a string like wire:submit.prevent="upload"
in your components's view file.
Livewire::test(FeedbackForm::class)
->assertContainsLivewireComponent(CategoryList::class);
You can use the component tag name as well:
Livewire::test(FeedbackForm::class)
->assertContainsLivewireComponent('category-list');
Livewire::test(FeedbackForm::class)
->assertContainsBladeComponent(Button::class);
You can use the component tag name as well:
Livewire::test(FeedbackForm::class)
->assertContainsBladeComponent('button');
Livewire::test(FeedbackForm::class)
->assertSeeBefore('first string', 'second string');
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.