mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-13 01:16:57 +08:00
1.4 KiB
1.4 KiB
title
| title |
|---|
| Testing |
Overview
All examples in this guide will be written using Pest. However, you can easily adapt this to PHPUnit.
Testing session notifications
To check if a notification was sent using the session, use the 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();
});
You may optionally pass a notification title to test for:
use Filament\Notifications\Notification;
use function Pest\Livewire\livewire;
it('sends a notification', function () {
livewire(CreatePost::class)
->assertNotified('Unable to create post');
});
Or test if the exact notification was sent:
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.'),
);
});