Notificaciones de prueba
Notificaciones de sesiones de prueba
Para verificar si se envió una notificación usando la sesión, use el asistente assertNotified():
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();
});
Opcionalmente, puede pasar un título de notificación para probar:
use Filament\Notifications\Notification;
use function Pest\Livewire\livewire;
it('sends a notification', function () {
livewire(CreatePost::class)
->assertNotified('Unable to create post');
});
O pruebe si se envió la notificación exacta:
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.'),
);
});
Por el contrario, puede afirmar que no se envió una notificación:
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.'),
);