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

Phpunit Watcher Laravel Package

spatie/phpunit-watcher

Automatically rerun PHPUnit tests whenever your code changes. Run phpunit-watcher watch to execute and re-execute tests on edits in app/src/tests. Supports passing through PHPUnit arguments (e.g. --filter) and works as a global tool or dev dependency.

View on GitHub
Deep Wiki
Context7

Getting Started

Install globally via composer global require spatie/phpunit-watcher, then run phpunit-watcher watch in any project directory to start automatic test reruns. The watcher will automatically detect changes in app, src, and tests directories and re-run PHPUnit on file modifications. This is ideal for TDD workflows—make a code change and immediately see test results without manual command repetition.

Implementation Patterns

  • Inline filtering: Pass PHPUnit arguments directly to the watch command, e.g., phpunit-watcher watch --filter=FeatureTest for targeted test cycles.
  • Config-driven setup: Create .phpunit-watcher.yml in project root to define persistent settings like watched directories, PHPUnit binary path, timeout, and initial arguments (e.g., --stop-on-failure). This ensures consistent behavior across team members.
  • Composer integration: Add "test:watch": "phpunit-watcher watch < /dev/tty" to composer.json scripts, and disable timeouts with Composer\\Config::disableProcessTimeout for full interactivity.
  • Nested config reuse: Leverage config lookup through parent directories for monorepos—place a shared config in the root and override only needed values in subdirectories.

Gotchas and Tips

  • TTY on Windows: Interactive commands (keyboard shortcuts) are disabled due to lack of TTY support; set all PHPUnit args during initial invocation only.
  • Performance tuning: For large repos, use exclude in config to omit directories like vendor/node_modules, and always specify fileMask: '*.php' to avoid watching non-PHP files.
  • Config precedence: CLI args override config file settings—test with --filter= after config is set to avoid surprises.
  • Desktop notifications: Disable failing/passing test notifications with notifications.failingTests: false to reduce noise during early development.
  • Hidden help tips: Set hideManual: true in config to suppress repetitive keyboard instruction text after each test run.
  • Config file lookup: The tool checks .phpunit-watcher.ymlphpunit-watcher.ymlphpunit-watcher.yml.dist and searches parent directories—ensure no stale config in parent folders overrides your project settings.
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.
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
anil/file-picker
broqit/fields-ai