I was successfully able to use my previous Laravel test watcher for a very long time, while I was on Linux. But now on Mac, it does not work, as mac does not support inotifywait.

Mac does however support similar thing, called fswatch, install via Brew:

brew install fswatch

However it works a little bit different than inotifywait, also the syntax differs, thus it is not a drop-in replacement. Now, I was able to quite quickly make it work for re-running all tests when anything PHP related changed, but they still take a few seconds to complete on my project and I had a hard time figuring out how to watch only a single file with fswatch. Once I figured it out, I thought I share it here, because I have not found any other source of this information anywhere else by simple searching:

fswatch --recursive --exclude="database.sqlite" \
  ./resources ./tests ./app ./routes ./database | xargs -n1 sh -c \
  './vendor/bin/sail exec -T laravel.test php artisan test --ansi tests/Feature/MyTest.php'

Works like a charm on my machine, perfectly emulating previous inotifywait functionality I was used to. Do not forget the --ansi switch, otherwise the color might be missing. Enjoy!