Appearance
Running Pest Tests in PHPStorm with Laravel Sail
This guide explains how to configure PHPStorm to run Pest tests inside your Laravel Sail Docker container. Pest is a modern PHP testing framework with an elegant syntax built on top of PHPUnit.
Prerequisites
- PHPStorm installed
- Laravel project with Sail configured
- Sail container running (
./vendor/bin/sail up -d) - Pest installed in your project
- CLI Interpreter already configured (see Running Tests with Sail)
Step 1: Install the Pest Plugin
First, install the Pest plugin in PHPStorm to get proper syntax highlighting and test runner support.
- Open Settings (
Ctrl+Alt+S) - Navigate to Plugins
- Search for Pest
- Install the official Pest plugin by JetBrains

Step 2: Configure CLI Interpreter
Make sure your CLI Interpreter is configured to connect to the existing Sail container. This is essential for running tests inside Docker.
- Open Settings → PHP → CLI Interpreter
- Select your laravel.test interpreter
- Under Lifecycle, ensure Connect to existing container is selected
TIP
Make sure Sail is running in the background before running tests.

Step 3: Add Pest Test Framework
- Go to Settings → PHP → Test Frameworks
- Click + to add a new test framework
- Select Pest (with the Remote interpreter)

Step 4: Configure Pest Path
Set the path to the Pest executable inside the Docker container:
- In the Pest library section, set Path to Pest executable:
/var/www/html/vendor/bin/pest

Step 5: Configure Path Mappings
Ensure the path mappings are correctly configured so PHPStorm knows how to map your local files to the container.
- Click on the folder icon next to Path mappings
- Add a mapping:
- Local Path: Your project root (e.g.,
/home/user/projects/my-app) - Remote Path:
/var/www/html
- Local Path: Your project root (e.g.,

Running Tests
Once configured, you can run Pest tests directly from the editor:
- Click the green play button next to a test function or
describeblock - Use
Ctrl+Shift+Rto run the test at cursor - Right-click on a test file and select Run
Troubleshooting
Tests fail with "Connection refused"
Make sure your Sail container is running:
bash
./vendor/bin/sail up -d
Pest executable not found
Verify Pest is installed in your project:
bash
./vendor/bin/sail composer require --dev pestphp/pest
Path mappings issues
Double-check that your local project path maps to /var/www/html in the container.