Weave 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

Pest Plugin Watch Laravel Package

pestphp/pest-plugin-watch

View on GitHub
Deep Wiki
Context7

Getting Started

Install the plugin via Composer:

composer require --dev pestphp/pest-plugin-watch

Then run tests in watch mode:

vendor/bin/pest --watch

This is ideal for TDD workflows—start the command and let it re-run tests automatically as files change. Check pest.php or config file (e.g., pest.php) for basic options like --only-changed or --retry-on-failure support via CLI flags.

Implementation Patterns

  • TDD Loop: Run pest --watch in a terminal alongside your editor. Modify test or source files, and watch tests re-run instantly.
  • CI/Local Dev Separation: Use Pest::beforeEach(fn () => $this->app->make('cache')->flush()) or custom event listeners inside your test suite to reset state before each run in watch mode—avoid side effects between re-runs.
  • Integrate with IDE: Set up a terminal panel (e.g., in PhpStorm or VS Code) to run pest --watch, and combine with --filter or --group for targeted retries.
  • Custom Watch Paths: Configure Pest::paths([...]) in pest.php to include or exclude directories beyond defaults (e.g., ->paths(['app/', 'tests/'])).

Gotchas and Tips

  • Stale File Handles: On macOS/Linux, avoid opening the same file in multiple editors or tools (e.g., tail -f, IDE auto-save conflicts), which can cause the React-based watcher to miss or double-fire events. Use rm -rf .pest/cache && vendor/bin/pest --watch to reset if stuck.
  • No Manual --stop-on-failure: This flag is ignored in watch mode—use Pest::failOnWarning(true) and Pest::failOnDeprecation(true) for stricter early feedback.
  • Restart Required for Config Changes: pest.php or .pest/ config changes won’t auto-reload mid-watch session. Press Ctrl+C and restart.
  • PHP 8.2+ Requirement: Ensure your environment meets the runtime dependency (^8.2.0). Use php -v to confirm.
  • Legacy Mode: If you see “watcher is not available” errors, verify react/child-process and react/event-loop are installed—some Composer lockfiles may exclude dev dependencies in production builds.
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.
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table