Skip to content

Vendor-neutral, engineer-written explanations. Clear definitions first, then practical steps with real examples — no fluff.

What is Laravel Dusk?

SB
Written by StageBit Engineering Team
Updated February 2026 2 min readVerified by engineers

Laravel Dusk is Laravel’s official, first-party browser automation and end-to-end testing solution. It allows developers to test real user interactions such as logging in, submitting forms, navigating pages, and validating JavaScript-driven interfaces using a real browser.

Laravel Dusk in Laravel

In Laravel, Laravel Dusk remains the recommended and officially supported engine for browser testing. While Pest 4 is now the preferred test runner due to its expressive syntax and performance, it works in tandem with Laravel Dusk rather than replacing it.

Developers can choose to write browser tests using either traditional class-based Dusk tests or Pest-powered Dusk tests. In both cases, Laravel Dusk remains the underlying browser automation technology.

How Laravel Dusk Works

Laravel Dusk controls a real browser using the WebDriver protocol. By default, it ships with a standalone ChromeDriver binary and does not require Selenium, Java, or a JDK. This makes browser testing simpler to set up compared to traditional Selenium-based solutions.

Dusk provides a fluent API for interacting with page elements, waiting for asynchronous events, and asserting UI behavior.

Installation and Setup

Laravel Dusk is installed as a development-only dependency and should never be enabled in production environments:

composer require laravel/dusk --dev
php artisan dusk:install

This command creates the tests/Browser directory, installs the appropriate ChromeDriver version, and generates an example browser test.

Environment Configuration

Dusk supports dedicated environment files such as .env.dusk.local. When running tests, Laravel temporarily swaps the environment configuration to ensure isolation from your main application.

Database Handling in Dusk

Laravel Dusk tests must not use the RefreshDatabase trait, as database transactions are not shared across browser processes. Instead, use DatabaseMigrations or DatabaseTruncation to reset database state safely.

Note: SQLite in-memory databases (:memory:) are not supported due to process isolation. However, file-based SQLite databases are fully supported and are commonly used for fast and isolated Dusk test environments.

Running Browser Tests

Browser tests are executed using the Dusk Artisan command:

php artisan dusk

You can re-run only failed tests or apply test filters using standard Pest or PHPUnit options.

Using Other Browsers

Although Chrome is the default browser, Laravel Dusk can connect to any Selenium-compatible browser by configuring a remote WebDriver. This makes it suitable for CI pipelines and cross-browser testing setups.

When to Use Laravel Dusk

  • Testing full user journeys and UI workflows
  • Validating JavaScript-heavy interfaces
  • Writing browser tests with Pest or PHPUnit syntax
  • End-to-end testing using Laravel’s official tooling

Was this answer helpful?

Your feedback helps us improve our answers.

Still need help?

Talk to our Laravel experts

We've handled GDPR/CCPA compliance for dozens of EU & US Laravel.

Talk to Laravel Experts

Tell us more about your brand!

Rohit Kundale, Our VP of Sales and Marketing is ready to meet with your team.