Laravel Dusk is a browser testing tool for Laravel applications that allows developers to perform end-to-end testing using a simple and expressive API. It automates browser interactions to verify application behavior.
Dusk was introduced by the Laravel team to simplify browser testing, providing developers with a built-in tool for verifying the front-end functionality of their applications.
Install Laravel Dusk:
composer require --dev laravel/dusk
php artisan dusk:install
Write a test:
namespace Tests\Browser;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class LoginTest extends DuskTestCase
{
public function testUserCanLogin()
{
$this->browse(function (Browser $browser) {
$browser->visit('/login')
->type('email', '[email protected]')
->type('password', 'password')
->press('Login')
->assertPathIs('/dashboard');
});
}
}
Run tests:
php artisan dusk
Laravel Dusk ensures your application's front-end behaves as expected, making browser testing simpler and more effective.