9 livewire testing- 2

PHOTO EMBED

Fri May 24 2024 05:08:19 GMT+0000 (Coordinated Universal Time)

Saved by @tsesang

    #[Test]
    public function title_is_required()
    {
        Livewire::test(CreatePost::class)
            ->set('title', '')
            ->call('save')
            // It checks if the validation rule 'required' is triggered for the 'title' empty string field after the form submission.
            ->assertHasErrors(['title' => 'required'])
            // It checks if the validation rule 'min:4' is triggered for the empty 'title' field after the form submission.
            ->assertHasErrors(['title' => 'min:4']);
    }
content_copyCOPY