wpstarter/dusk
Laravel Dusk browser automation and testing for WP Starter/Laravel-style apps. Write expressive end-to-end tests using a standalone Chromedriver by default (no JDK/Selenium required), with the option to use other Selenium drivers.
php-webdriver (renamed from facebook/webdriver) and Chromedriver, which are well-documented but require local setup (e.g., Chrome installation). Docker (via Laravel Sail) can mitigate this.--parallel) or selective test scoping (e.g., @dusk tags) can optimize execution.waitFor(), waitUntil()) to handle async operations.test() functions) or PHPUnit for legacy compatibility.AuthenticateSession), enabling real-world auth flows in tests.dusk, dusk:fails, dusk:purge) for test management.assertVue*() methods) and jQuery, aligning with Laravel’s frontend stack.composer require --dev laravel/dusk
npm install --save-dev chrome-chromedriver # or use Sail
.env:
DUSK_DRIVER_CHROME_PATH=/path/to/chrome
DUSK_DRIVER_CHROME_ARGUMENTS=["--no-sandbox", "--headless"]
main or nightly).laravelsail/php81-chrome).DuskTestCase in phpunit.xml or pest.php:
<testsuites>
<testsuite name="Feature">
<directory>./tests/Browser</directory>
</testsuite>
</testsuites>
php artisan dusk:assets
tests/Browser/AuthenticationTest.php).InteractsWithBrowsers, InteractsWithPages) for reusable logic.php artisan dusk
DUSK_DRIVER_CHROME_ARGUMENTS="--headless --disable-gpu" php artisan dusk
laravel/dusk and php-webdriver for breaking changes. Pin versions in composer.json:
"require-dev": {
"laravel/dusk": "^6.25",
"php-webdriver/webdriver": "^1.9"
}
TESTING.md with:
ElementNotInteractableException).--browse flag to manually inspect failed tests.assertSource() to compare HTML snapshots.screenshot() for visual debugging.App\Exceptions\Handler) to log Dusk failures.sleep()).--parallel or PHPUnit’s --parallel to distribute tests across CI workers.--headless in CI to reduce resource usage.laravelsail/php81-chrome) to avoid setup issues.@slow, @visual) to filter tests by performance impact.| Failure Type | Root Cause | Mitigation |
|---|---|---|
| Flaky Tests | Race conditions, async waits | Use |
How can I help you explore Laravel packages today?