Append ->only() to any Pest test declaration to execute only that specific test without writing long CLI filter strings.
Filtering specific test names via CLI flags like --filter requires typing exact strings. Appending ->only() to a test declaration silences all other tests in the file.
test('calculates order total with discounts', function () {
expect(true)->toBeTrue();
})->only(); // Only this test will run!
test('another test', function () {
// Skipped
});
- Focuses test runner execution strictly on tagged test cases
- Avoids typing long CLI --filter flags during debugging sessions
- Remember to remove ->only() before committing changes
Related Tips
View all tips →
Pest PHP
Testing
Enable Compact Test Output Printer in Pest
Use the --compact flag or set it in your composer.json test script for minimal single-character test progress indicators.
READ
>
Pest PHP
Testing
Clean Up Pest Test Configuration in tests/Pest.php
Organize base test case bindings, helper functions, and global traits cleanly inside tests/Pest.php.
READ
>