
pest-testing-setup
by mwguerra
MWGuerra Claude Code Marketplace
SKILL.md
name: pest-testing-setup description: Set up Pest testing with Orchestra Testbench for Laravel packages allowed-tools: Bash(python3:), Bash(composer:), Write, Read, Glob
PestPHP Testing Setup Skill
Adds complete PestPHP testing infrastructure to an existing Laravel package.
Usage
When the user wants to add testing to an existing package:
python3 ${SKILL_DIR}/scripts/setup_pest_testing.py <vendor/package-name> [options]
Options
--filament- Include Filament/Livewire testing utilities--with-coverage- Add code coverage configuration--with-ci- Add GitHub Actions CI workflow
Examples
Basic testing setup
python3 ${SKILL_DIR}/scripts/setup_pest_testing.py mwguerra/my-package
With Filament support
python3 ${SKILL_DIR}/scripts/setup_pest_testing.py mwguerra/filament-blog --filament
Full setup with CI
python3 ${SKILL_DIR}/scripts/setup_pest_testing.py mwguerra/my-package --with-coverage --with-ci
What Gets Created/Updated
Files Created
-
phpunit.xml - PHPUnit configuration
- Code coverage for
src/directory - Unit and Feature test suites
- Testing environment variables
- APP_KEY for Laravel testing
- Code coverage for
-
tests/Pest.php - PestPHP configuration
- TestCase binding for all tests
- Custom expectations setup
- Helper functions section
-
tests/TestCase.php - Orchestra TestCase
- Package service provider registration
- Testing database configuration
- Environment setup
- Migration handling
-
tests/Unit/ExampleTest.php - Sample unit test
- Environment verification
- Service provider registration test
- Basic package functionality test
-
tests/Feature/.gitkeep - Feature tests directory
-
.github/workflows/tests.yml (if --with-ci)
- GitHub Actions workflow
- Multi-PHP version testing
- Code coverage reporting
composer.json Updates
{
"require-dev": {
"orchestra/testbench": "^10.0",
"pestphp/pest": "^3.8",
"pestphp/pest-plugin-laravel": "^3.1"
},
"autoload-dev": {
"psr-4": {
"Vendor\\PackageName\\Tests\\": "tests/"
}
},
"scripts": {
"test": "pest",
"test-coverage": "pest --coverage"
}
}
Note: Uses latest versions for Laravel 11/12 compatibility:
- Orchestra Testbench ^10.0 - For Laravel 11 & 12
- PestPHP ^3.8 - Latest stable
- Pest Plugin Laravel ^3.1 - Latest stable
Running Tests
After setup:
# Navigate to package
cd packages/vendor/package-name
# Install dependencies (including dev)
composer install
# Run all tests
./vendor/bin/pest
# Run with coverage
./vendor/bin/pest --coverage
# Run specific test file
./vendor/bin/pest tests/Unit/ExampleTest.php
# Run filtered tests
./vendor/bin/pest --filter="service provider"
# Run in parallel
./vendor/bin/pest --parallel
Writing Tests
Basic Test Structure
test('it does something', function () {
// Arrange
$data = ['key' => 'value'];
// Act
$result = processData($data);
// Assert
expect($result)->toBeTrue();
});
Testing Service Provider
test('service is registered', function () {
expect($this->app->bound('my-service'))->toBeTrue();
});
Testing Commands
test('command runs successfully', function () {
$this->artisan('my-package:command')
->expectsOutput('Success!')
->assertSuccessful();
});
Testing with Database
uses(RefreshDatabase::class);
test('it creates model', function () {
$model = MyModel::create(['name' => 'Test']);
expect($model)->toBeInstanceOf(MyModel::class);
$this->assertDatabaseHas('my_models', ['name' => 'Test']);
});
Testing Livewire Components (Filament)
use Livewire\Livewire;
test('component renders', function () {
Livewire::test(MyComponent::class)
->assertSee('Expected text')
->assertStatus(200);
});
Best Practices
- One assertion per test - Keep tests focused
- Descriptive names - Test names should describe behavior
- Arrange-Act-Assert - Structure tests clearly
- Test edge cases - Empty arrays, null values, boundaries
- Use datasets - For testing multiple scenarios
- Mock external services - Don't call real APIs in tests
Filament testing
When --filament is enabled, tests should follow Filament’s guidance:
- Filament components are Livewire components; use
livewire()/Livewire::test(). - Test Resources via their URLs and their underlying Livewire components.
- Use table/schema/action helpers to assert columns, filters, actions, and notifications.
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon