How to Run Laravel Dusk Tests

Now that we are ready with Laravel Dusk setup, we will go over on how to run the Laravel Dusk test.

For laravel dusk to be able to run the browser automation test on your local environment, It needs to know your application url.

For this, Go to your environment file .env , and set the APP_URL property to be your application url. This value should match the URL you use to access your application in the browser.

To run your dusk test run the following artisan command from your terminal / CLI

Livewire Component Library
php artisan dusk

If you are on fresh Laravel installation and have the basic installation of dusk ready, then you should have a Browser folder under your tests directory and it should have an ExampleTest.php dusk test file.

Host Laravel Application on DigitalOcean

Use coupon 5balloons on this Cloudways Affiliate URL to get special discount.

This is what this file contains.


namespace Tests\Browser;

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

class ExampleTest extends DuskTestCase
     * A basic browser test example.
     * @return void
    public function testBasicExample()
        $this->browse(function (Browser $browser) {

Running the artisan dusk commands executes all the tests in your Browser directory. Currently we only have one, this test verifies that we see the text Laravel when we visit the application’s home page.


If you had test failures the last time you ran the dusk command, you may save time by re-running the failing tests first using the dusk:fails command:

php artisan dusk:fails

The dusk command accepts any argument that is also accepted by the phpunit command:

Thus, if you want to run a single dusk test you can use the following command

php artian dusk --filter testBasicExample

Next up, you can learn how to see your Tests running in browser by turning off headless mode.

Udemy Laravel Dusk Course

Laravel Dusk Beginner to Advanced

Video Course on Automation Testing, Web Scraping and Creating Bots using Dusk

> 60% OFF

Limited Time Offer

Learn More

Site Footer