Watch Plugin

Overview

The Watch plugin keeps an eye on your application and automatically runs your Pest tests when you change files inside specific directories.

Note: This is still a development package and needs further testing.

Installation

Follow these two steps to install it:

  1. Install fswatch on your machine, or check if you already have it:
fswatch --version
  1. Install the Watch plugin using Composer:
composer require pestphp/pest-plugin-watch --dev

Once the installation is finished, your Pest CLI will have a new --watch option available.

Running Watch

Running pest --watch starts Pest in watch mode and, from this point on, any file modification inside the directories will trigger Pest to run your tests.

pest --watch # Night gathers, and now my watch begins

Default directories

By default, the Watch plugin observes the following directories:

  • tests/
  • app/
  • src/

Custom directories

If you need to watch a custom set of directories, just provide a comma-separated list to the --watch flag.

Example:

pest --watch=app,routes,tests

The command will watch the app, routes, and tests directories.

Next section: Creating Plugins →