bencarter78
5 months ago

Setting up Dusk with testing database

Posted 5 months ago by bencarter78

Hello

I'm having real issues with getting Dusk to work with a testing database. I seem to have gone through every piece of advice and still no luck. Dusk is not loading my .env.dusk.local file for some reason. Can anyone help?

// test
class ApplicationTest extends DuskTestCase
{
    use DatabaseMigrations;

    /** @test */
    public function it_works()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/test')->assertSee('It works!');
        });
    }
}

// .env.dusk.local
APP_NAME="Laravel"
APP_ENV=local
APP_URL=http://127.0.0.1:8000

DB_CONNECTION=dusk

// database.php
'dusk' => [
    'driver' => 'sqlite',
    'database' => database_path('dusk.sqlite'),
    'prefix' => '',
]

Then I run the PHP web server with php artisan serve --env=dusk.local however Dusk uses the .env file and goes to my development site using the development database.

What am I doing wrong?

Please sign in or create an account to participate in this conversation.