Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Testbench Dusk Laravel Package

orchestra/testbench-dusk

Helper for testing Laravel packages with Laravel Dusk. Provides a Testbench-based setup to run browser tests in a package development workflow, maintained under the Orchestra namespace with ongoing support and community contributions.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Purpose Alignment: The package bridges Laravel Testbench (unit/package testing) and Laravel Dusk (browser automation), enabling seamless E2E testing for Laravel packages. This is a critical fit for packages requiring UI/UX validation (e.g., admin panels, form integrations, or CLI-driven workflows).
  • Modularity: Leverages Testbench’s isolation capabilities (e.g., tweakApplication()beforeServingApplication()) to mock dependencies, making it ideal for packages with complex Laravel integrations (e.g., service providers, middleware, or event listeners).
  • Dusk-Specific Optimizations: Pre-configures Dusk to disable Chrome flags (--disable-search-engine-choice-screen, --disable-smooth-scrolling), reducing flakiness in CI/CD pipelines—a high-value feature for automated testing.

Integration Feasibility

  • Dependency Stack:
    • Laravel 13+ (v11.0.0+) and PHP 8.5+ (v10.8.0+) are required, aligning with modern Laravel ecosystems.
    • Testbench Core v11.3.0+ and Dusk v8.5.0+ are mandatory, which may require upgrades for legacy projects.
    • PHPUnit 12.x support ensures compatibility with contemporary testing workflows.
  • Package Isolation: Designed to work alongside existing Testbench setups, minimizing conflicts with other testing tools (e.g., PestPHP).
  • Skeleton Integration: Improves vendor detection in default Testbench skeletons, streamlining boilerplate setup.

Technical Risk

  • Version Lock-In: Tight coupling with specific versions of Testbench/Dusk may require frequent updates to avoid compatibility issues (e.g., Laravel 13’s breaking changes).
  • Dusk Overhead: Browser automation introduces slower test execution (10–100x vs. unit tests), necessitating selective use (e.g., critical UI flows only).
  • CI/CD Complexity: Requires ChromeDriver setup and maintenance, adding infrastructure overhead (e.g., Docker configurations for headless testing).
  • Deprecations: Methods like tweakApplication() are deprecated in favor of beforeServingApplication(), requiring refactoring in existing test suites.

Key Questions

  1. Use Case Justification:
    • Are E2E tests for package UI/UX critical to your product’s quality gates, or can unit/integration tests suffice?
    • What percentage of test coverage will Dusk add vs. existing Testbench tests?
  2. Stack Compatibility:
    • Does your project use Laravel 13+ and PHP 8.5+? If not, what’s the upgrade path?
    • Are you using Testbench v11.3.0+? If not, what’s the migration effort?
  3. Infrastructure Readiness:
    • Is your CI/CD pipeline configured for headless Chrome/Dusk (e.g., GitHub Actions, GitLab CI)?
    • Do you have ChromeDriver version alignment with your Dusk setup?
  4. Performance Trade-offs:
    • Can Dusk tests be parallelized or run in a separate pipeline to avoid slowing down unit tests?
    • Are there flaky tests in your current Dusk suite that could be mitigated by this package?
  5. Maintenance Burden:
    • Who will monitor updates to Testbench/Dusk and ensure compatibility?
    • How will you handle deprecated methods in existing test suites?

Integration Approach

Stack Fit

  • Primary Use Case: Ideal for Laravel packages with UI components, form interactions, or CLI-driven workflows that require E2E validation.
  • Secondary Use Case: Useful for packages integrating with third-party frontend frameworks (e.g., Livewire, Inertia.js) where DOM behavior must be tested.
  • Non-Fit Scenarios:
    • Packages with no UI layer (e.g., pure API services, background jobs).
    • Projects already using alternative E2E tools (e.g., Cypress, Playwright) with deep customizations.

Migration Path

  1. Prerequisite Setup:
    • Upgrade Laravel to v13+ and PHP to 8.5+.
    • Install Testbench v11.3.0+ and Dusk v8.5.0+.
    • Ensure ChromeDriver is installed and version-aligned with Dusk.
  2. Package Installation:
    composer require --dev orchestra/testbench-dusk
    
  3. Test Suite Migration:
    • Replace tweakApplication() with beforeServingApplication() in existing tests.
    • Extend Orchestra\TestbenchDusk\TestCase for Dusk-specific tests:
      use Orchestra\TestbenchDusk\TestCase;
      
      class ExampleTest extends TestCase {
          public function test_package_ui() {
              $this->browse(function (Browser $browser) {
                  $browser->visit('/package-route')
                          ->assertSee('Expected UI Element');
              });
          }
      }
      
  4. CI/CD Configuration:
    • Add Dusk-specific environment variables (e.g., DUSK_BROWSER=chrome).
    • Configure Chrome flags in .env:
      DUSK_CHROME_ARGS="--disable-search-engine-choice-screen --disable-smooth-scrolling"
      
    • Example GitHub Actions workflow:
      jobs:
        test-dusk:
          runs-on: ubuntu-latest
          steps:
            - uses: actions/checkout@v4
            - uses: actions/setup-node@v4
            - uses: shivammathur/setup-php@v2
              with:
                php-version: '8.5'
            - run: composer install
            - run: composer test-dusk
      

Compatibility

  • Testbench Core: Must align with v11.0.0+ (check orchestra/testbench compatibility).
  • Dusk: Requires v8.5.0+ (Laravel 10/11 compatibility).
  • PHPUnit: Supports v12.x (drop-in replacement for v9.x).
  • Laravel: v13+ only (v12.x may work but is unsupported).

Sequencing

  1. Phase 1: Integrate into existing Testbench suite (low risk).
  2. Phase 2: Migrate critical UI tests to Dusk (medium risk).
  3. Phase 3: Optimize CI/CD for parallel execution (high impact).
  4. Phase 4: Deprecate legacy tweakApplication() calls (breaking change).

Operational Impact

Maintenance

  • Dependency Updates:
    • Frequency: High (Testbench/Dusk/Laravel updates may break compatibility).
    • Effort: Moderate (automated dependency checks + manual testing).
  • ChromeDriver Management:
    • Requires version pinning to avoid Dusk failures (e.g., 114.0.5735.90 for Dusk v8.5.0).
    • CI/CD pipelines must auto-update ChromeDriver alongside Dusk.
  • Test Flakiness:
    • Dusk tests are more prone to flakiness (network latency, race conditions).
    • Mitigation: Use wait() methods, retry logic, or exclude flaky tests.

Support

  • Debugging Complexity:
    • Dusk failures often require manual inspection (screenshots, logs).
    • Testbench’s isolation may hide package-specific issues (e.g., missing service providers).
  • Community Resources:
    • Limited dependent packages (0) may reduce third-party support.
    • Orchestra maintains the package but may lack urgent issue resolution for edge cases.
  • Documentation Gaps:
    • Official docs are basic; expect to rely on Testbench/Dusk docs for advanced use cases.

Scaling

  • Test Execution Time:
    • Unit Tests: ~1–5 sec each.
    • Dusk Tests: ~10–30 sec each (10x slower).
    • Mitigation: Run Dusk tests in parallel or nightly batches.
  • Resource Requirements:
    • Each Dusk test spawns a Chrome instance (~500MB–1GB RAM).
    • CI/CD may need larger runners (e.g., GitHub’s large or xlarge).
  • CI/CD Pipeline Bottlenecks:
    • Queueing: Dusk tests may block faster unit tests if not separated.
    • Solution: Dedicated Dusk pipeline or conditional execution (e.g., only: ['@dusk']).

Failure Modes

Failure Type Root Cause Impact Mitigation
Dusk Test Flakiness Network latency, race conditions Intermittent test failures Retry logic, wait() methods
**ChromeDriver Mism
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope