How to install laravel dusk to do browser testing for your application?

Laravel Dusk provides an easy-to-use browser automation using chromedriver installation.

Install composer dependency for your application

composer require --dev laravel/dusk

Now execute below artisan command

php artisan dusk:install

Set the APP_URL env variable in the .env file. This value should match the URL you use to access your application in a browser.

Create a test

php artisan dusk:make HomepageTest

namespace Tests\Browser;

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

class HomepageTest extends DuskTestCase
     * A Dusk test example.
     * @return void
    public function testExample()
        $this->browse(function (Browser $browser) {

Run test

php artisan dusk

This will run the test and open up a chrome browser for you.

$ php artisan dusk

The output of the test case will be displayed as below:

$ php artisan dusk
 Warning: TTY mode is not supported on Windows platform.
 PHPUnit 9.5.4 by Sebastian Bergmann and contributors.
 DevTools listening on ws://
 DevTools listening on ws://
 .                                                                  2 / 2 (100%)
 Time: 00:05.610, Memory: 22.00 MB
 OK (2 tests, 2 assertions)