Organize base test case bindings, helper functions, and global traits cleanly inside tests/Pest.php.
Duplicate uses() declarations across every test file clutters test suites. Centralize common test traits (like RefreshDatabase or TestCase classes) inside tests/Pest.php grouped by directory.
// tests/Pest.php
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
uses(TestCase::class, RefreshDatabase::class)->in('Feature');
uses(TestCase::class)->in('Unit');
- Centralizes global traits like RefreshDatabase for specific test folders
- Eliminates repetitive uses() imports across individual test files
- Defines custom expectation helpers globally for all test suites
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
Focus Test Runs Instantly with Pest ->only() Method
Append ->only() to any Pest test declaration to execute only that specific test without writing long CLI filter strings.
READ
>