Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bwrigley's avatar

Dusk and Homestead -- struggling to get it running

I'm trying to get Dusk running for my Laravel/Vue project that's running in my Homestead environment.

I'm running Homestead in a Win10 environment

I've followed installation from the docs:

composer require --dev laravel/dusk
php artisan dusk:install

And I've made sure my APP_URL is the address I'm using to access my test site from my windows environment

I've also made sure my Homestead.yaml has:

features:
    - webdriver: true

and I've created the demo login test:

<?php

namespace Tests\Browser;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;

class LoginTest extends DuskTestCase
{

    use RefreshDatabase;
    /**
     * A Dusk test example.
     */
    public function testExample(): void
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')
                    ->assertSee('Laravel');
        });
    }
}

when I run php artisan dusk it seems to timeout:

1) Tests\Browser\LoginTest::testExample
Facebook\WebDriver\Exception\TimeoutException: timeout: Timed out receiving message from renderer: 10.000
  (Session info: chrome=114.0.5735.198)

Any thoughts about where I'm going wrong?

p.s. artisan dusk -vvv doesn't seem to change the output to the terminal...

0 likes
1 reply
bwrigley's avatar
bwrigley
OP
Best Answer
Level 5

After a great deal of exploration, I have finally solved this.

In my case, using Homestead in windows, I am running my vite server in a windows terminal but not for lack of trying*

So for my test running inside Homestead, it needs to be able to access the vite server running on windows

Running npm run dev -- showed me the local IP that vite was using

Then in vite.config.js

export default defineConfig({
    esbuild: {
        jsxFactory: 'h',
        jsxFragment: 'Fragment'
      },
    plugins: [
        laravel({
            input: 'resources/js/app.js',
            refresh: true,
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
    ],
    server: {
        hmr: {
          host: "192.168.10.1", <-- this was the IP exposed in previous step
        },
        host: "0.0.0.0", <-- this allows other IPs to connect N.B. 0.0.0.0 means any IP!
    },
});

Now when I run dusk it can see the vite server rather than having to build assets every time I run the tests

Hope this helps someone else!

  • I tried installing vite inside Homestead, but npm install was failing trying to create symlinks. I had to then restart vagrant from a windows terminal running as admin. This allowed me to install everything and then run vite.

However, I have using vscode as my editor and I have learned that as I'm changing files vite was not registering the change. From the vite docs:

"Using Vite on Windows Subsystem for Linux (WSL) 2

When running Vite on WSL2, file system watching does not work when a file is edited by Windows applications (non-WSL2 process). This is due to a WSL2 limitation. This also applies to running on Docker with a WSL2 backend.

To fix it, you could either:

Recommended: Use WSL2 applications to edit your files. It is also recommended to move the project folder outside of a Windows filesystem. Accessing Windows filesystem from WSL2 is slow. Removing that overhead will improve performance. Set { usePolling: true }. Note that usePolling leads to high CPU utilization."

And yes, userPolling:true made my server crawl to a halt.

1 like

Please or to participate in this conversation.