The power of Laravel Dusk, a browser automation testing tool

The power of Laravel Dusk, a browser automation testing tool


Laravel Dusk is a tool which provides an expressive, easy-to-use browser automation and testing API. Practically its just another PHP package for your project to fully functional browser tests.

By default, Dusk does not require you to install JDK or Selenium on your machine. Instead, Dusk uses a standalone ChromeDriver installation. However, you are free to utilize any other Selenium compatible driver you wish.

The Laravel Dusk installation is simple, after composer package installation just have to run:

php artisan dusk:install

The best thing is you can use all the power of Laravel framework for your browser tests as well. For instance, using Laravel Model Factories to seed data for your tests.

Using other browsers with Laravel Dusk

With laravel dusk you may start your own Selenium server and run your tests against any browser you wish. You just have to stop using ChromeDriver while preparing your instance in file tests/DuskTestCase.php

Environment handling in Laravel Dusk

We can create all together separate environment for dusk tests by just creating separate .env file for that dusk. To force Dusk to use its own environment file when running tests, create a .env.dusk.{environment} file in the root of your project. For example, if you will be initiating the dusk command from your local environment, you should create a .env.dusk.local file.

Vuejs Assertions with Laravel Dusk

Laravel Dusk even allows you to make assertions on the state of Vue component data(Isn't is awesome :)). For example, imagine your application contains the following Vue component:

// HTML...
<profile dusk="profile-component"></profile>
// Component Definition...
Vue.component('profile', {
    template: '<div>{{ }</div>',
    data: function () {
        return {
            user: {
              name: 'Taylor'

You may assert on the state of the Vue component like so:

public function testVue()
    $this->browse(function (Browser $browser) {
                ->assertVue('', 'Taylor', '@profile-component');

There are so many available assertions with proper documentation about them.