write test for validating fields on the custom form component
I have a custom filament form component with two fields, prompt and SKU, I want to write a test suite for validating the form. Below is the test I have written to do the same but it says the component doesn't have errors
it('will return validation notification submitting invalid data', function () {
$component = livewire(MagentoForm::class)
->fillForm([
'prompt' => 1,
'sku' => ''
])
->assertHasFormErrors(['sku' => 'The sku field is required.']);
});
5 Replies
'sku' => null
?Not working.
Yes. I did.
The validation errors are not trapped since it is a custom livewire component.
For better clarity, I will explain what happened. I had to integrate a multi-form to a custom page. So I created a Livewire component https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component and set a form like below:
I have added 2 forms to the page https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#using-multiple-forms. When I write tests for validation messages, It says the form doesn't return any validation errors