# Run PHPUnit and Pest Tests Without Vite Assets in Laravel

Ashley Allen · 29th October 2025

## Introduction

A common way to build your Laravel application's frontend assets is with Vite (by running a command such as `npm run dev` or `npm run build`). You can then use Laravel's handy `@vite` [Blade directive](/content/blog/boost-your-laravel-templates-with-custom-blade-directives/index.html) to include those built assets in your views.

On page load, Laravel will then look for a `manifest.json` file in your `public/build` directory to determine which CSS and JavaScript assets to load.

But sometimes, you might want to run your PHPUnit or Pest tests without needing to build your assets with Vite first. For example, let's take this test, which checks that the welcome page can be returned:

```
         1declare(strict_types=1);
 2
 3namespace Tests\Feature;
 4
 5use PHPUnit\Framework\Attributes\Test;
 6use Tests\TestCase;
 7
 8final class WelcomeTest extends TestCase
 9{
10    #[Test]
11    public function welcome_page_can_be_returned(): void
12    {
13        $this->get('/')
14            ->assertOk()
15            ->assertViewIs('welcome');
16    }
17}
```

In the test, we're just asserting that when we visit the `/` route, the welcome page is returned and that it uses the correct view. We're not inspecting anything in the view itself, so it's not necessary to build our assets with Vite.

However, if our page is using the `@vite` directive, and we haven't built our assets, then we'll get an error like this when running the above test:

```
        1Expected response status code [200] but received 500.
2Failed asserting that 500 is identical to 200.
3
4The following exception occurred during the last request:
5
6Illuminate\Foundation\ViteManifestNotFoundException: Vite manifest not found at: /Users/ashallen/www/laravel-app/public/build/manifest.json
```

Let's quickly explore how to avoid this error and run your PHPUnit and Pest tests for your Laravel application without needing to build your assets with Vite. We'll also explain the benefits of this approach.

## Run PHPUnit Tests without Vite

If you're using PHPUnit for your tests, you can disable Vite for individual test classes by using the `withoutVite` method. You can add this to the `setUp` method of your test class like so:

```
         1declare(strict_types=1);
 2
 3namespace Tests\Feature;
 4
 5use PHPUnit\Framework\Attributes\Test;
 6use Tests\TestCase;
 7
 8final class WelcomeTest extends TestCase
 9{
10    protected function setUp(): void
11    {
12        parent::setUp();
13
14        $this->withoutVite();
15    }
16
17    #[Test]
18    public function welcome_page_can_be_returned(): void
19    {
20        $this->get('/')
21            ->assertOk()
22            ->assertViewIs('welcome');
23    }
24}
```

Typically, you wouldn't want to add this to every test class, though. Instead, you might want to add it to your base test case class so that it applies to all your tests:

```
         1namespace Tests;
 2
 3use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
 4
 5abstract class TestCase extends BaseTestCase
 6{
 7    protected function setUp(): void
 8    {
 9        parent::setUp();
10
11        $this->withoutVite();
12    }
13}
```

This now means that all your tests will run without needing to build your assets with Vite.

## Run Pest Tests without Vite

Alternatively, let's say you're using Pest and your test looks like this:

```
        1test('welcome page can be returned', function () {
2    $this->get('/')
3        ->assertOk()
4        ->assertViewIs('welcome');
5});
```

You can disable Vite for all the tests in the `Feature` directory/suite by using the `withoutVite` method in your `tests/Pest.php` file:

```
        1pest()->extend(Tests\TestCase::class)
2    ->in('Feature')
3    ->beforeEach(function () {
4        $this->withoutVite();
5    });
```

You'll now be able to run your Pest tests without needing to build your assets with Vite first.

## Benefits of Running Tests Without Vite

There may be times when you actually require your assets to have been built for your tests to run correctly. For example, if you're using something like Laravel Dusk, Playwright, or Cypress to run browser tests that interact with your frontend, then you'll likely need to build your assets with Vite first.

But unless you're running these types of tests, it's unlikely you'll need to do so.

As a result of not building your assets with Vite, it can speed up your testing process. This is especially true if you're running your tests in a continuous integration (CI) environment, such as GitHub Actions. You can save time by skipping the Node dependency installation and asset build steps. As a result, your CI pipeline can then run faster, giving you quicker feedback on your code changes.

## Conclusion

Hopefully, this Quickfire article has shown you how to run your PHPUnit and Pest tests in Laravel without needing to build your assets with Vite first.

If you enjoyed reading this post, you might be interested in checking out my 220+ page ebook " [Battle Ready Laravel](https://battle-ready-laravel.com/)" which covers similar topics in more depth.

Or, you might want to check out my other 440+ page ebook " [Consuming APIs in Laravel](https://consuming-apis-in-laravel.com/)" which teaches you how to use Laravel to consume APIs from other services.

Keep on building awesome stuff! 🚀
