Filling a form
To fill a form with data, pass the data tofillform():
Note that if you have multiple forms on a Livewire component, you can specify which form you want to fill using fillForm([...], 'createPostForm').
To check that a form has data, use assertFormSet():
Note that if you have multiple forms on a Livewire component, you can specify which form you want to check using assertFormSet([...], 'createPostForm').
Validation
UseassertHasFormErrors() to ensure that data is properly validated in a form:
assertHasNoFormErrors() to ensure there are no validation errors:
Note that if you have multiple forms on a Livewire component, you can pass the name of a specific form as the second parameter likeassertHasFormErrors(['title' => 'required'], 'createPostForm')orassertHasNoFormErrors([], 'createPostForm').
Form existence
To check that a Livewire component has a form, useassertFormExists():
Note that if you have multiple forms on a Livewire component, you can pass the name of a specific form like assertFormExists('createPostForm').
Fields
To ensure that a form has a given field pass the field name toassertFormFieldExists():
Note that if you have multiple forms on a Livewire component, you can specify which form you want to check for the existence of the field like assertFormFieldExists('title', 'createPostForm').
Hidden fields
To ensure that a field is visible pass the name toassertFormFieldIsVisible():
assertFormFieldIsHidden():
Note that for bothassertFormFieldIsHidden()andassertFormFieldIsVisible()you can pass the name of a specific form the field belongs to as the second argument likeassertFormFieldIsHidden('title', 'createPostForm').
Disabled fields
To ensure that a field is enabled pass the name toassertFormFieldIsEnabled():
assertFormFieldIsDisabled():
Note that for bothassertFormFieldIsEnabled()andassertFormFieldIsDisabled()you can pass the name of a specific form the field belongs to as the second argument likeassertFormFieldIsEnabled('title', 'createPostForm').