Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Update Vite mock to return empty array for preloadedAssets #44858

Merged
merged 3 commits into from
Nov 7, 2022

Conversation

jryd
Copy link
Contributor

@jryd jryd commented Nov 7, 2022

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 base TestCase.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.

@taylorotwell taylorotwell merged commit 29430b4 into laravel:9.x Nov 7, 2022
@jryd jryd deleted the bugfix/preloaded-assets-in-vite-mock branch November 7, 2022 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants