- How do I install Laravel Dusk without needing Selenium or JDK?
- Dusk ships with a bundled Chromedriver, so you only need Chrome (≥115) installed. Run `composer require --dev laravel/dusk` and `php artisan dusk:install` to auto-configure everything. No JDK or Selenium setup is required unless you switch to another driver.
- Can I use Laravel Dusk with Laravel 10–13 and PHP 8.4–8.5?
- Yes, Dusk officially supports Laravel 10–13 and PHP 8.1+. For PHP 8.4–8.5, ensure your `composer.json` pins Dusk to v8.x (latest stable). Check the [Laravel docs](https://laravel.com/docs/dusk) for version-specific quirks.
- How do I test Vue.js or React components with Dusk?
- Dusk provides helper methods like `assertVueContains()` and `assertReactContains()` for SPAs. For client-side routing, use `waitForLocation()` to ensure the browser waits for Vue Router/React Router transitions before assertions.
- Will Dusk work in CI/CD pipelines like GitHub Actions?
- Yes, Dusk is CI-friendly. Use `php artisan dusk` or `php artisan dusk --headless=new` for headless Chrome. Pre-install Chrome/Chromedriver in your CI environment or use Docker. Parallel testing is supported via the `--parallel` flag.
- How do I debug flaky tests in Dusk?
- Use `waitFor()` methods (e.g., `waitForText()`, `waitForElement()`) to handle timing issues. For visual debugging, take screenshots with `elementScreenshot()` or `browser->screenshot()`. Slow down tests with `pause(5000)` for manual inspection.
- Can I use Firefox or Edge instead of Chrome with Dusk?
- Yes, Dusk supports alternative Selenium drivers. Set the `DUSK_DRIVER` env var to `firefox` or `edge` and ensure the corresponding driver is installed. Example: `php artisan dusk --driver=firefox`. Check [Dusk’s docs](https://laravel.com/docs/dusk#driver-configuration) for setup.
- Is Laravel Dusk suitable for unit testing, or only end-to-end?
- Dusk is designed for **end-to-end** and UI regression testing, not unit testing. For unit tests, use Laravel’s built-in `HttpTests` or Pest. Dusk validates full user flows (e.g., form submissions, auth workflows) across the entire stack.
- How do I run Dusk tests in parallel for faster CI execution?
- Use the `--parallel` flag with `php artisan dusk --parallel=N`, where `N` is the number of browsers. Set `DUSK_BROWSERS=chrome,firefox` in your `.env` for multi-browser parallelism. Ensure your CI environment has enough resources for concurrent tests.
- Does Dusk support testing Laravel queues or background jobs?
- Yes, Dusk can interact with queues. Use `queue:flush` in your tests to clear pending jobs, or assert job processing with `browser->assertSeeInDatabase()`. For testing job failures, simulate them with `Artisan::call('queue:work --daemon')` in your test setup.
- What are the alternatives to Laravel Dusk for browser testing?
- Alternatives include **Puppeteer** (Node.js), **Playwright** (multi-language), or **Selenium WebDriver** (Java/Python). Dusk stands out for Laravel apps due to its native integration (e.g., `actingAs()` for auth) and bundled Chromedriver. For non-Laravel projects, Playwright or Cypress may offer more flexibility.