- How does testbench-dusk differ from running Laravel Dusk tests directly in a package?
- Testbench-dusk provides a preconfigured environment tailored for package development, automatically handling Testbench’s application lifecycle hooks (like `beforeServingApplication()`) and isolating package-specific Dusk tests. Without it, you’d need to manually set up a Laravel app and manage Dusk’s dependencies, which is cumbersome for package testing.
- Can I use testbench-dusk with Laravel 13 and PHP 8.5?
- Yes, testbench-dusk supports Laravel 10–13 and PHP 8.5+. Ensure you’re using Testbench Core v11.0.0+ and Laravel Dusk v8.3.5+ to avoid compatibility issues. Check the [official docs](https://packages.tools/testbench-dusk.html) for version-specific setup instructions.
- How do I install testbench-dusk in my Laravel package?
- Add it to your `composer.json` under `require-dev`: `"orchestra/testbench-dusk": "^11.0"`. Then run `composer install`. You’ll also need `laravel/dusk` and `phpunit/phpunit` as dev dependencies. ChromeDriver must be installed separately (e.g., via `dusk:chrome-driver` or Docker).
- Will testbench-dusk work with Pest instead of PHPUnit?
- No, testbench-dusk is built for PHPUnit and Testbench. If you’re using Pest, consider `pest-plugin-dusk` for Dusk integration. Testbench-dusk relies on PHPUnit’s test lifecycle and Testbench’s hooks, which aren’t compatible with Pest’s architecture.
- How do I handle ChromeDriver version mismatches in CI vs. local?
- Use Docker for consistent ChromeDriver versions across environments. Alternatively, pin ChromeDriver in CI using `dusk:chrome-driver` or manually install a specific version. Avoid relying on system-installed Chrome, as its version may drift. Testbench-dusk doesn’t manage ChromeDriver—you’ll need to handle this separately.
- Can I run Dusk tests in parallel with testbench-dusk?
- Yes, but you’ll need to configure PHPUnit’s parallel testing manually. Testbench-dusk doesn’t enforce parallelism, so ensure your test classes are namespaced to avoid collisions. Run tests with `phpunit --parallel` or use CI tools like GitHub Actions’ matrix strategy for parallel execution.
- How do I mock or stub package dependencies in Dusk tests?
- Use Testbench’s `tweakApplication()` method (if needed) or leverage Dusk’s built-in browser mocking. For package-specific dependencies, override them in your test’s `setUp()` or use Testbench’s `beforeServingApplication()` hook to modify the Laravel container before Dusk boots the browser.
- Is testbench-dusk stable enough for production package testing?
- It’s in active development but stable for core functionality. The package is early-stage (0 dependents) and relies on Testbench/Dusk, which are battle-tested. Monitor the [GitHub repo](https://github.com/orchestral/testbench-dusk) for updates. For critical projects, consider forking or contributing feedback to the Orchestra team.
- How do I debug flaky Dusk tests in testbench-dusk?
- Flakiness often stems from environmental factors like network delays or Chrome updates. Use Dusk’s `refreshDusk()` to reset the browser state between tests. Run tests in headless mode (`--headless`) to reduce variability. If issues persist, check ChromeDriver logs or use `pause()` in your test to inspect the browser manually.
- What alternatives exist for testing Laravel packages with Dusk?
- For Pest users, `pest-plugin-dusk` is a lightweight alternative. If you need more modern browser automation, consider Playwright, though it requires additional setup. For pure backend testing, stick with Testbench alone—testbench-dusk is specifically for UI/integration workflows and isn’t a replacement for unit tests.