- What is orchestra/testbench-dusk used for?
- It is a Laravel Dusk testing helper for Laravel package development. It combines Testbench with Dusk so package authors can run browser-based end-to-end tests without building a full Laravel application. It is maintained under the Orchestra namespace and is intended for package test suites, not application testing.
- How do I install orchestra/testbench-dusk?
- Install it with Composer as a development dependency, for example composer require --dev orchestra/testbench-dusk. You also need compatible Testbench and Laravel Dusk versions in your package's dev dependencies. After installation, extend Orchestra\TestbenchDusk\TestbenchDuskTestCase in your Dusk test classes.
- Which Laravel versions does orchestra/testbench-dusk support?
- The package is intended to work with the Laravel and Testbench versions it declares in its Composer constraints, with the assessment noting Testbench v11+ and Dusk v8.3.5+ aligned with Laravel 10/11/13. Because Laravel and Dusk evolve quickly, check the package's composer.json and release notes before upgrading. PHP 8.5+ compatibility is noted for future-proofing in the assessment.
- How do I write a Dusk browser test for a Laravel package with Testbench Dusk?
- Create a test class that extends Orchestra\TestbenchDusk\TestbenchDuskTestCase and use Dusk's browse method to visit routes and make assertions. You can override beforeServingApplication to adjust package configuration or service providers before the test application boots. Place these tests in a dedicated directory such as tests/Dusk.
- Do I need ChromeDriver to use Testbench Dusk?
- Yes, because Testbench Dusk builds on Laravel Dusk, which traditionally relies on ChromeDriver for browser automation. Your local and CI environments need a compatible Chrome or Chromium binary and driver setup. The assessment notes that a future Dusk migration to Playwright could affect this requirement, so monitor Dusk release notes.
- How do I override package configuration in Testbench Dusk tests?
- Use the beforeServingApplication hook in your TestbenchDuskTestCase subclass to change configuration before the application is served. For example, call config(['my-package.setting' => true]) inside that method. This replaces older approaches such as tweakApplication, which the assessment notes is deprecated in favor of beforeServingApplication.
- Is orchestra/testbench-dusk production ready?
- It is a development-only testing helper, so it is not something you ship in production code. The README describes it as early development, and the assessment notes limited adopters and possible undocumented edge cases. Use it for package test suites, pin compatible versions, and review changes before upgrading.
- How is Testbench Dusk different from Laravel Dusk?
- Laravel Dusk is the browser testing tool for Laravel applications, while Testbench Dusk adapts Dusk for package development using Testbench's package bootstrapping. It reduces boilerplate for serving a test application and configuring package providers during browser tests. You still use Dusk's browser APIs and assertions in your tests.
- Can I run Testbench Dusk tests in GitHub Actions?
- Yes, but you need to set up a browser and driver in the CI environment, such as headless Chrome/Chromium with ChromeDriver. The assessment includes an example using google-chrome headless and CHROME_BIN with DUSK_DRIVER=chrome. Run these Dusk tests separately from or alongside your unit tests, and consider parallelization for larger suites.
- What are alternatives to orchestra/testbench-dusk for Laravel package testing?
- For non-browser tests, use Testbench Core, PHPUnit, or Pest to test service providers, facades, and package logic. For browser tests, you can set up native Laravel Dusk in a test application or use other E2E tools. Testbench Dusk is most useful when you want Dusk browser coverage without maintaining a full Laravel app skeleton.