When using a view with @vite, and using that view in unit testing, it returns the error Vite manifest not found at home/projects/laravel/public/build/manifest.json.
While this is indeed true (there is no manifest), it's bonkers when requiring it on unit testing.
Steps To Reproduce:
Create a view with @vite() ponting to any random javascript entrypoint.
Create a test that returns the view.
See it explode.
This is valid too on the feature test:
public function test_vite_why(): void
{
Files::put('resources/js/test.js', '');
Files::put('resources/views/test.blade.php', "@vite('resources/js/test.js')");
Route::get('test', function () {
return view('test');
});
$this->get('test')->assertOk();
}
Possible solution
Add a simple check inside Vite::manifest() that can returns an empty array if not found on unit testing.
if (! is_file($path)) {
if (app()->runningUnitTests()) {
return [];
}
throw new Exception("Vite manifest not found at: {$path}");
}
Description:
When using a view with
@vite
, and using that view in unit testing, it returns the errorVite manifest not found at home/projects/laravel/public/build/manifest.json
.While this is indeed true (there is no manifest), it's bonkers when requiring it on unit testing.
Steps To Reproduce:
@vite()
ponting to any random javascript entrypoint.This is valid too on the feature test:
Possible solution
Add a simple check inside
Vite::manifest()
that can returns an empty array if not found on unit testing.