#[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']); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter