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

Laravel Dusk helper for Laravel package development. Integrates with Orchestra Testbench to run browser tests against a package’s test app, making it easier to write and maintain Dusk suites for packages.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Strengths:

    • Seamless Laravel Dusk integration: Designed specifically for Testbench-powered package development, eliminating the need for a full Laravel install while preserving Dusk’s browser-testing capabilities.
    • Minimalist abstraction: Leverages Testbench’s existing application bootstrapping (e.g., tweakApplication()beforeServingApplication()) to maintain consistency with Laravel’s testing ecosystem.
    • CI/CD-ready: Pre-configured for GitHub Actions (via workflows) and supports headless Chrome options (--disable-search-engine-choice-screen, --disable-smooth-scrolling) for faster test execution.
    • Version alignment: Actively maintained with Laravel 13, Testbench 11+, and Dusk 8.3.5+ support, ensuring compatibility with modern stacks.
  • Gaps:

    • Limited adoption: No dependents (0) suggests niche use case or early-stage adoption; risk of underutilized community support.
    • Dusk-specific: Does not cover non-browser tests (e.g., API, unit tests), requiring parallel Testbench usage.
    • Deprecation footprints: Active deprecation of tweakApplication() (replaced by beforeServingApplication()) may require refactoring in existing test suites.

Integration Feasibility

  • Prerequisites:

    • Requires Testbench (orchestra/testbench) as a dependency (v11.0.0+ for v11.x of this package).
    • Laravel Dusk (v8.3.5+) must be installed separately (not bundled).
    • PHPUnit 12.x support (mandatory for v10.x+; earlier versions may need polyfills).
    • ChromeDriver for browser automation (handled via Dusk’s dusk:chrome-driver command).
  • Compatibility Risks:

    • Package isolation: Tests may inadvertently leak between packages if not properly namespaced (e.g., shared routes, middleware).
    • Headless vs. visual testing: CI environments may struggle with visual assertions (e.g., screenshots) without manual configuration.
    • Laravel version lock-in: Tight coupling to Laravel’s release cycles (e.g., v11.0.0 requires Laravel 13).

Technical Risk

  • Medium-High:
    • Dependency sprawl: Adds Testbench + Dusk + ChromeDriver to the stack, increasing maintenance overhead.
    • Test flakiness: Dusk tests are prone to environmental variability (e.g., network delays, Chrome updates).
    • Learning curve: Requires familiarity with Testbench’s PackageServiceProvider and Dusk’s DuskTestCase for effective use.
    • CI complexity: Headless Chrome setup in CI (e.g., GitHub Actions) may need custom Docker containers or self-hosted runners.

Key Questions

  1. Use Case Validation:

    • Is the primary goal UI/integration testing for Laravel packages (e.g., admin panels, form builders), or are unit/API tests sufficient?
    • Will the team adopt Testbench alongside this package, or is there resistance to adding another testing layer?
  2. Stack Alignment:

    • Does the target Laravel version (e.g., 10.x vs. 13.x) align with the package’s supported range?
    • Are there existing Dusk tests that could be migrated, or is this a greenfield effort?
  3. Resource Commitment:

    • Who will maintain ChromeDriver updates and CI infrastructure (e.g., Docker images)?
    • Is there budget for visual regression testing tools (e.g., Percy, Applitools) if needed?
  4. Alternatives:

    • Could Playwright or Cypress replace Dusk for broader browser support?
    • Is PestPHP (with browser extensions) a lighter alternative to Testbench + Dusk?

Integration Approach

Stack Fit

  • Primary Use Case: Laravel package development requiring end-to-end UI testing (e.g., validating admin interfaces, form submissions, or real-time dashboards).

  • Stack Compatibility:

    Component Version Support Notes
    Laravel 13.x (v11.0.0+) Tight coupling; downgrades may break.
    Testbench 11.x+ Core dependency; align versions.
    Laravel Dusk 8.3.5+ Separate install; ChromeDriver needed.
    PHPUnit 12.x Mandatory for v10.x+.
    PHP 8.5+ v10.8.0+ supports PHP 8.5.
  • Non-Fit Scenarios:

    • Non-Laravel projects: Incompatible without significant refactoring.
    • API-only packages: Overkill; use Testbench’s HTTP tests instead.
    • Legacy Laravel (<10.x): Requires older package versions (e.g., v7.x), increasing maintenance risk.

Migration Path

  1. Assessment Phase:

    • Audit existing tests: Identify Dusk-compatible tests vs. unit/API tests.
    • Validate Laravel/Testbench/Dusk versions: Ensure no conflicts with composer.json.
  2. Setup:

    composer require --dev orchestra/testbench-dusk orchestra/testbench laravel/dusk
    composer require --dev phpunit/phpunit:^12
    
    • Configure phpunit.xml to extend Orchestra\TestbenchDusk\TestCase.
    • Add ChromeDriver to CI (e.g., GitHub Actions):
      services:
        chrome:
          image: chromium/browser:latest
      
  3. Test Migration:

    • Convert existing Dusk tests to use TestbenchDuskTestCase:
      use Orchestra\TestbenchDusk\TestCase;
      
      class ExampleTest extends TestCase {
          protected function getPackageProviders($app) {
              return ['YourPackage\ServiceProvider'];
          }
      }
      
    • Replace tweakApplication() with beforeServingApplication() in legacy tests.
  4. CI/CD Integration:

    • Add Dusk-specific workflows (e.g., dusk:chrome-driver setup).
    • Example GitHub Actions snippet:
      - name: Install ChromeDriver
        run: |
          CHROME_DRIVER_VERSION=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
          wget -O chromedriver https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
          unzip chromedriver -d /usr/bin/
      

Compatibility

  • Sequencing:

    1. Unit/API Tests: Use Testbench’s core (orchestra/testbench) for non-browser tests.
    2. UI Tests: Layer testbench-dusk on top for Dusk-specific scenarios.
    3. Visual Testing: Add tools like Percy if regression testing is needed.
  • Conflict Mitigation:

    • Namespace collisions: Use unique test namespaces (e.g., Tests\Dusk\PackageName).
    • Shared state: Reset Testbench’s application state between tests (e.g., refreshApplication()).
    • Headless mode: Force --headless=new in CI to avoid Chrome UI prompts.

Sequencing Recommendations

Phase Priority Tasks
Version Alignment Critical Pin Testbench, Dusk, and Laravel versions in composer.json.
Test Isolation High Refactor tests to avoid shared state (e.g., database, routes).
CI Setup High Containerize ChromeDriver and Dusk dependencies.
Deprecation Fixes Medium Replace tweakApplication() in legacy test suites.
Visual Testing Low Evaluate tools like Percy for regression testing (post-MVP).

Operational Impact

Maintenance

  • Pros:

    • Reduced boilerplate: Testbench Dusk abstracts Laravel app setup, cutting test initialization time.
    • Orchestra-backed: Future updates are likely (maintained under Orchestra namespace).
    • GitHub Actions templates: Pre-configured workflows for CI/CD (e.g., analyse.yaml).
  • Cons:

    • Dependency updates: Requires coordinated updates for:
      • Testbench (orchestra/testbench)
      • Laravel Dusk (laravel/dusk)
      • ChromeDriver (separate from Composer)
    • Test flakiness: Dusk tests may fail intermittently due to:
      • Network latency in CI.
      • Chrome version mismatches.
      • Dynamic content (e.g., timestamps, CSRF tokens).
    • Debugging complexity: Browser-based test failures are harder to diagnose than unit tests.
  • Mitigation:

    • Automated testing: Use GitHub Actions to run Dusk tests on every PR.
    • Retries: Implement retry logic for flaky tests (e.g
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests