- How do I use Select2 dropdowns in Laravel Dusk browser tests?
- Install the package as a dev dependency and use its Dusk helper to interact with Select2 fields instead of driving the widget with raw JavaScript. The helper lets you pick an option by its visible text or by its underlying value, which keeps your browser tests readable. This avoids the common problems of clicking hidden native selects or waiting on Select2's generated markup.
- How do I install roquie/laravel-dusk-select2 with Composer?
- Add it with Composer in your require-dev section, since it exists to support browser tests rather than application runtime code. Because version 2.1.0 depends on laravel/dusk rather than the full laravel/framework, Composer will pull Dusk and its own dependencies into your development install. After installing, make sure Dusk is set up in your application and your browser driver is available before running the suite.
- Should this package be a dev dependency or a production dependency?
- Treat it strictly as a dev dependency. It is a test-automation helper that works alongside Laravel Dusk, so it has no place in production runtime paths, and version 2.1.0 moving to laravel/dusk reinforces that intent. Installing it in require rather than require-dev would ship Dusk and browser-testing dependencies into your deployed application for no benefit.
- Which Laravel and PHP versions does this package support?
- The release notes for 2.1.0 do not publish an explicit support matrix for Laravel, PHP, PHPUnit, or Dusk, so you should confirm compatibility from the package's composer.json and CI configuration before adopting it. Check the constraints against the Laravel and PHP versions your application actually runs on. If you are upgrading from 1.x, verify that the newer Dusk-based dependency resolution still works with your pinned framework version.
- What changed between the 1.x, 2.0, and 2.1.0 releases?
- The most significant architectural change is that the package now depends on laravel/dusk instead of the full laravel/framework, which trims the transitive dependency footprint. The 2.0 release is where the breaking surface lives, so review those changes before upgrading, and treat 2.1.0 as a follow-up release on top of it. Release notes also mention maintainer-side hygiene such as PHPUnit schema updates, test namespace changes, CI fixes, and a removed composer.lock, none of which should change your usage of the helper itself.
- Will requiring laravel/dusk conflict with the Dusk version already in my project?
- It can, depending on the constraints your application already declares. Since 2.1.0 requires laravel/dusk directly, Composer has to find a single Dusk version that satisfies both the package and your application, and conflicting constraints will fail resolution. Test the upgrade on a branch first and let Composer report any conflicts rather than forcing an install with --ignore-platform-reqs or update --with-all-dependencies without review.
- Can I use this package without Laravel Dusk installed?
- No, Dusk is the foundation for this helper. The package exists to extend Dusk's browser testing with Select2-aware interactions, and version 2.1.0 declares laravel/dusk as a dependency. If you are not already running Dusk tests, you would need to add Dusk, configure a browser driver such as ChromeDriver, and accept the overhead of a browser test suite before this package is useful to you.
- How do I select a Select2 option by value rather than visible text?
- The package exposes helpers for picking options both by the text a user sees and by the option's underlying value, which is useful when labels are localized or duplicated. Consult the repository README for the exact method signatures in your installed version, since 2.x is a new major line. If a lookup does not resolve, check whether the Select2 instance has finished loading its data, especially for AJAX-backed dropdowns.
- Why did the package drop laravel/framework and remove composer.lock?
- Depending on laravel/dusk instead of the full framework makes the package lighter and better aligned with its role as a test-only tool, reducing transitive coupling in your development install. Removing composer.lock is normal for a library, because consumers resolve dependencies from their own lockfiles. The practical consequence is that reproducibility now depends on the package's CI configuration and on your application's committed lockfile, so pin a known-good version in your own project.
- What are the alternatives to a Select2 Dusk helper package?
- You can drive Select2 manually in Dusk by executing JavaScript that sets the underlying select element and dispatches a change event, but that approach tends to be brittle across Select2 versions and themes. Another option is to bypass the widget in tests by exercising the underlying form endpoint or by using a simpler native select in your test environment. A small helper such as this one is generally less maintenance than maintaining your own JS snippets across a test suite.