laravel/dusk
Laravel Dusk is a browser automation and end-to-end testing tool for Laravel. It provides an expressive API for driving real browsers, ships with a standalone Chromedriver (no Selenium/JDK required by default), and can use other Selenium drivers.
Laravel Dusk is a native fit for Laravel-based applications, offering seamless integration with the Laravel ecosystem. It leverages Laravel’s testing utilities (e.g., Tests\CreatesApplication) and integrates with PHPUnit/Pest for test execution. The package’s architecture aligns with Laravel’s conventions, making it ideal for:
Key strengths:
Dusk\Page classes.dusk:install, DUSK_DRIVER_URL config).Potential challenges:
| Risk Area | Mitigation Strategy |
|---|---|
| Driver compatibility | Pin Chromedriver version in dusk:install or use DUSK_DRIVER_URL for custom setups. |
| Test flakiness | Use waitFor() assertions, disable animations, and implement retry logic. |
| CI/CD setup | Containerize tests (Docker) to ensure consistent environments. |
| Maintenance burden | Adopt POM for reusable test components; avoid hardcoding selectors. |
| Legacy Laravel | Dusk v8+ drops PHPUnit 9/Laravel 9 support; ensure compatibility with target versions. |
Dusk is optimized for Laravel stacks but can integrate with broader PHP ecosystems:
composer require --dev laravel/dusk
php artisan dusk:install
DUSK_DRIVER_URL (e.g., http://localhost:9515) and browser options in .env.services:
chrome:
image: selenium/standalone-chrome:latest
LoginPage, CheckoutPage).--parallel flag.dusk:test for local debugging with headed mode.Compatibility risks:
DUSK_DRIVER_URL configuration.waitForVue()).Tests\CreatesApplication exists)..env.Best practices:
Page classes to reduce duplication.browser->screenshot() or elementScreenshot() for failed tests.storage/logs/dusk.DUSK_HEADLESS=false for local debugging.waitFor() or waitForText() to handle async operations.Support resources:
--parallel or Pest’s native parallelism.How can I help you explore Laravel packages today?