livewire()->fillForm() not working

I have several tests using the same helper. All tests are working except for one, and I can't figure out why. I'm going to leave the simplest example possible just to show the problem: VehicleTest:
it('works', function () {
livewire(CreateVehicle::class)
->fillForm([
'plate' => 'someplate',
])
->assertFormSet([
'plate' => 'someplate',
]);
});
it('works', function () {
livewire(CreateVehicle::class)
->fillForm([
'plate' => 'someplate',
])
->assertFormSet([
'plate' => 'someplate',
]);
});
VehicleResource:
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('plate'),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('plate'),
]);
}
CreateVehicle:
class CreateVehicle extends CreateRecord
{
protected static string $resource = VehicleResource::class;
}
class CreateVehicle extends CreateRecord
{
protected static string $resource = VehicleResource::class;
}
That exact test is not working, giving: Failed asserting that null matches expected 'someplate' Even though it works if I manually create that vehicle in the actual page.
Solution:
change to testing
Jump to solution
7 Replies
LeandroFerreira
LeandroFerreira5mo ago
dd(app()->runningUnitTests()); in the test, what is the output?
Bruno Silva
Bruno SilvaOP5mo ago
false
LeandroFerreira
LeandroFerreira5mo ago
env testing in the phpunit.xml? <env name="APP_ENV" value="testing"/>
Bruno Silva
Bruno SilvaOP5mo ago
value = local
Solution
LeandroFerreira
LeandroFerreira5mo ago
change to testing
Bruno Silva
Bruno SilvaOP5mo ago
worked... thanks very much, why did my other tests keep working but this one? all of them were using the exact same helpers
Want results from more Discord servers?
Add your server