简体   繁体   中英

Setting up Laravel Dusk with testing database

VERSIONS: Laravel v5.8.21 & Laravel Dusk v5.1.0

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?

I think you might need to update Laravel. Are you using an older version of the framework? This used to be a bug pre-5.8.7. See: https://github.com/laravel/framework/issues/27828

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM