[9.x] Update Vite mock to return empty array for preloadedAssets #44858
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
The Vite mock that is used when using
$this->withoutVite()
inside tests uses__call
to proxy all method calls that aren't explicitly defined to return an empty string.This conflicts with the
\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class
middleware which expects this to be an empty array.Long Version
I recently created a new Laravel project and installed Breeze.
I'm using Vue and Inertia and bootstrapped this through Breeze.
We've been writing tests as we've gone and this has all worked fine locally.
Today, I added a CI workflow for our project, via GitHub Actions, and got failures.
I was not installing and building assets, and it was failing due to a missing Vite manifest.
I added
$this->withoutVite()
to the baseTestCase.php
and then saw failures due to the\Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class
middleware as the assets were not coming through as an empty array but an empty string.Looking under the hood, the mock that exists in the
InteractsWithContainer
, I can see that this will be due to__call
forcing a string to return.I've added a test to the
InteractsWithContainerTest
that highlights the issue.