Testing failing

I don't understand my test is fail.
it('can validate input', function () {
livewire(CreateJob::class)
->fillForm([
'title' => null,
])
->assertHasFormErrors(['title' => 'required']);
});
-------------------------------------------
TextInput::make('title')
->label('Title')
->minLength(2)
->maxLength(100)
->string()
->required(),
it('can validate input', function () {
livewire(CreateJob::class)
->fillForm([
'title' => null,
])
->assertHasFormErrors(['title' => 'required']);
});
-------------------------------------------
TextInput::make('title')
->label('Title')
->minLength(2)
->maxLength(100)
->string()
->required(),
12 Replies
Shaung Bhone
Shaung BhoneOP2y ago
Failed asserting that false is true.
Failed asserting that false is true.
Patrick Boivin
I'm not 100% sure but I think you would need to trigger the validation before checking for assertHasFormErrors() Try calling a form method like ->call('submit') or something equivalent Also I'm using ->assertHasErrors() instead of the other one, not sure if that makes a difference...
LeandroFerreira
livewire(CreateJob::class)
->fillForm([
'title' => null,
])
->call('create')
->assertHasFormErrors(['title' => 'required']);
livewire(CreateJob::class)
->fillForm([
'title' => null,
])
->call('create')
->assertHasFormErrors(['title' => 'required']);
Shaung Bhone
Shaung BhoneOP2y ago
it('can validate input', function () {
livewire(CreateJob::class)
->fillForm([
'title' => null,
])
->call('create')
->assertHasFormErrors(['title' => 'required']);
});
it('can validate input', function () {
livewire(CreateJob::class)
->fillForm([
'title' => null,
])
->call('create')
->assertHasFormErrors(['title' => 'required']);
});
still failing. LOL it's not working
LeandroFerreira
same error? should work... can you share the resource code?
Shaung Bhone
Shaung BhoneOP2y ago
yes Which resource code? I've already shared you. 🥹
test('employer can create their job posts', function () {
livewire(CreateJob::class)
->fillForm([
'title' => fake()->name(),
'description' => fake()->text(500),
//
])
->call('create')
->assertHasNoFormErrors();
})->group('create job post');
test('employer can create their job posts', function () {
livewire(CreateJob::class)
->fillForm([
'title' => fake()->name(),
'description' => fake()->text(500),
//
])
->call('create')
->assertHasNoFormErrors();
})->group('create job post');
that's worked.
Patrick Boivin
But this is not the same test 😄 has errors / has no errors...
Shaung Bhone
Shaung BhoneOP2y ago
yes I dont understand where am I do wrong? https://github.com/livewire/livewire/issues/490
LeandroFerreira
should work Can you share the project on github?
Shaung Bhone
Shaung BhoneOP2y ago
Can I invite you through gmail? it's private.
Shaung Bhone
Shaung BhoneOP2y ago
wait. I will share you gist. https://gist.github.com/ShaungBhone/fb80b7913472930168de5698ee21b130 @pboivin LOL I need actingAs.
Want results from more Discord servers?
Add your server