How to install and use Laravel Dusk

Description of Laravel Dusk

Laravel Dusk is a fantastic browser-based testing framework to test your entire web application from end-to-end. Why we love it is because it’s easy to do form and workflow testing on website front-ends. This article explains how to install and use Laravel Dusk.


laravel new project
cd project
composer require --dev laravel/dusk
php artisan dusk:install

There is already a sample test in /tests/Browser so you’ll be able to use the command below straight away to test:

php artisan dusk

Once you have a few tests going, annotate your comments so that you can run individual tests instead of the whole suite every time:

php artisan dusk --group=foo

Here is an example to get the above to work:

cat /tests/Browser/SearchFormTest.php

class SearchFormTest extends DuskTestCase

use withFaker;

* A basic browser test example.
* @group foo
* @return void
* @throws \Throwable
public function testSearchForm()
    $this->browse(function (Browser $browser) {

Viewing Output Errors

By default when Dusk scrapes your application it will produce an error page in /tests/browser/screenshots. If you, however, want to always see the final output, add this:



Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top