testing uploads with Pest

Hi, does someone have a test example for file uploads with Pest?, I can't find any resource
5 Replies
Dan Harrin
Dan Harrin2y ago
try ->fillForm(['fileuploadname.0' => UploadedFile::fake()])
Javier Mercedes
Javier MercedesOP2y ago
I have it like this, now I want to get the uploaded file name after the upload to confirm is uploaded to the server
Dan Harrin
Dan Harrin2y ago
as i said, you need .0
Javier Mercedes
Javier MercedesOP2y ago
Ok, I'll try
bwurtz999
bwurtz9996mo ago
Does this change for an action? I get an error when I try and run this (I am testing a CreateAction from a Manange page)
// this works
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
// 'menu.0' => UploadedFile::fake(),
])
->assertHasNoActionErrors();

// this does not work
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
'menu.0' => UploadedFile::fake(),
])
->assertHasNoActionErrors();

// this does not work either
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
'menu' => [
UploadedFile::fake(),
]
])
->assertHasNoActionErrors();

// this is the error I get
Property type not supported in Livewire for property: [{}]
at vendor/livewire/livewire/src/Mechanisms/HandleComponents/HandleComponents.php:491
// this works
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
// 'menu.0' => UploadedFile::fake(),
])
->assertHasNoActionErrors();

// this does not work
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
'menu.0' => UploadedFile::fake(),
])
->assertHasNoActionErrors();

// this does not work either
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
'menu' => [
UploadedFile::fake(),
]
])
->assertHasNoActionErrors();

// this is the error I get
Property type not supported in Livewire for property: [{}]
at vendor/livewire/livewire/src/Mechanisms/HandleComponents/HandleComponents.php:491
I am using use Illuminate\Http\UploadedFile;
Want results from more Discord servers?
Add your server