Test FileUpload
I can't test my FileUpload
I have this test:
This test PASSES.
If I uncomment the line
the test fails on line
with the following error:
I tried all the solutions I could find online, without success...
Solution:Jump to solution
I found the solution!
```php
->set('data.name', 'Test')
->set('data.file.0' => UploadedFile::fake()->create('file.pdf', 100, 'application/pdf'))...
2 Replies
I think you have to somehow persist the fake() to the livewire-tmp directory. UploadedFile doesn’t return an instance of TemporaryFileUpload, so it doesn’t know how to handle it.
Probably need to fake the Storage too.
Solution
I found the solution!
I got it from a Dan Harrin's answer on github. You have to add
.0
after the field name.
Be careful, the following doesn't work: