Search code examples
laravellaravel-dusklaravel-5.8laravel-dusk2

Laravel Serve command does not respect --env parameter


To be able to run Browser tests directly in my IDE (without using the artisan dusk command), I want to run php artisan serve --env=dusk.local. While it indeed starts the local PHP server, it uses the wrong database. It uses the database specified in .env not the one in .env.dusk.local.
I ran php artisan cache:clear thousands of times, but it doesn't change anything.
Running things like php artisan migrate --env=... works.

Is there a way to achieve my goal without needing to rename my .env.dusk.local file to .env before each test?


Solution

  • This is a bug in Laravel 5.8: https://github.com/laravel/framework/issues/27828

    There is currently no solution (other than downgrading to Laravel 5.7).

    It has been fixed in the latest release 5.8.7.