Testing session notifications
To check if a notification was sent using the session, use theassertNotified() helper:
📣 New official plugin released: Custom Dashboards! Create data-driven dashboards using a drag and drop UI.
assertNotified() helper:
use function Pest\Livewire\livewire;
it('sends a notification', function () {
livewire(CreatePost::class)
->assertNotified();
});
use Filament\Notifications\Notification;
it('sends a notification', function () {
Notification::assertNotified();
});
use function Filament\Notifications\Testing\assertNotified;
it('sends a notification', function () {
assertNotified();
});
use Filament\Notifications\Notification;
use function Pest\Livewire\livewire;
it('sends a notification', function () {
livewire(CreatePost::class)
->assertNotified('Unable to create post');
});
use Filament\Notifications\Notification;
use function Pest\Livewire\livewire;
it('sends a notification', function () {
livewire(CreatePost::class)
->assertNotified(
Notification::make()
->danger()
->title('Unable to create post')
->body('Something went wrong.'),
);
});
use Filament\Notifications\Notification;
use function Pest\Livewire\livewire;
it('does not send a notification', function () {
livewire(CreatePost::class)
->assertNotNotified()
// or
->assertNotNotified('Unable to create post')
// or
->assertNotNotified(
Notification::make()
->danger()
->title('Unable to create post')
->body('Something went wrong.'),
);