Help us improve
Share bugs, ideas, or general feedback.
From fuse-laravel
Write tests with Pest 3/PHPUnit, feature tests, unit tests, mocking, fakes, and factories. Use when testing controllers, services, models, or implementing TDD.
npx claudepluginhub fusengine/agents --plugin fuse-laravelHow this skill is triggered — by the user, by Claude, or both
Slash command
/fuse-laravel:laravel-testingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Before ANY implementation, use `TeamCreate` to spawn 3 agents:
references/console-tests.mdreferences/database-assertions.mdreferences/database-basics.mdreferences/database-factories.mdreferences/http-assertions.mdreferences/http-auth.mdreferences/http-json.mdreferences/http-requests.mdreferences/mocking-fakes.mdreferences/mocking-http.mdreferences/mocking-services.mdreferences/pest-arch.mdreferences/pest-basics.mdreferences/pest-datasets.mdreferences/templates/ApiTest.php.mdreferences/templates/ArchTest.php.mdreferences/templates/FeatureTest.php.mdreferences/templates/PestConfig.php.mdreferences/templates/UnitTest.php.mdreferences/troubleshooting.mdGuides TDD workflow for Laravel with PHPUnit/Pest: unit/feature/integration tests, factories, DB strategies (RefreshDatabase), fakes, and 80%+ coverage targets.
Provides Laravel testing strategies using PHPUnit, Pest, model factories, HTTP tests, Sanctum authentication, and mocking for TDD workflows.
Guides Test-Driven Development for Laravel apps using Pest PHP: write failing tests first for features, bug fixes, controllers, models, APIs, then minimal code to pass and refactor.
Share bugs, ideas, or general feedback.
Before ANY implementation, use TeamCreate to spawn 3 agents:
After implementation, run fuse-ai-pilot:sniper for validation.
| Type | Purpose | Location |
|---|---|---|
| Feature | HTTP, full stack | tests/Feature/ |
| Unit | Isolated classes | tests/Unit/ |
| Arch | Code architecture | tests/Arch.php |
What to test?
├── HTTP endpoint → Feature test
├── Service/Policy logic → Unit test
├── Code structure → Arch test
├── External API → Mock with Http::fake()
├── Mail/Queue/Event → Use Fakes
└── Database state → assertDatabaseHas()
Coverage strategy?
├── Feature tests (70%) → Critical flows
├── Unit tests (25%) → Business logic
├── E2E tests (5%) → User journeys
└── Arch tests → Structural rules
pest --parallel for speed| Topic | Reference | When to Consult |
|---|---|---|
| Pest Syntax | pest-basics.md | it(), test(), describe() |
| Datasets | pest-datasets.md | Data providers, hooks |
| Architecture | pest-arch.md | arch() tests |
| Topic | Reference | When to Consult |
|---|---|---|
| Requests | http-requests.md | GET, POST, headers |
| JSON API | http-json.md | API assertions |
| Authentication | http-auth.md | actingAs, guards |
| Assertions | http-assertions.md | Status, redirects |
| Topic | Reference | When to Consult |
|---|---|---|
| Basics | database-basics.md | RefreshDatabase |
| Factories | database-factories.md | Factory patterns |
| Assertions | database-assertions.md | DB assertions |
| Topic | Reference | When to Consult |
|---|---|---|
| Services | mocking-services.md | Mock, spy |
| Fakes | mocking-fakes.md | Mail, Queue, Event |
| HTTP & Time | mocking-http.md | Http::fake, travel |
| Topic | Reference | When to Consult |
|---|---|---|
| Console | console-tests.md | Artisan tests |
| Troubleshooting | troubleshooting.md | Common errors |
| Template | When to Use |
|---|---|
| FeatureTest.php.md | HTTP feature test |
| UnitTest.php.md | Service unit test |
| ArchTest.php.md | Architecture test |
| ApiTest.php.md | REST API test |
| PestConfig.php.md | Pest configuration |
// Feature test
it('creates a post', function () {
$user = User::factory()->create();
$this->actingAs($user)
->postJson('/api/posts', ['title' => 'Test'])
->assertCreated()
->assertJsonPath('data.title', 'Test');
$this->assertDatabaseHas('posts', ['title' => 'Test']);
});
// With dataset
it('validates emails', function (string $email, bool $valid) {
// test logic
})->with([
['valid@test.com', true],
['invalid', false],
]);
// Mock facade
Mail::fake();
// ... action ...
Mail::assertSent(OrderShipped::class);
# Run all tests
php artisan test
# Pest directly
./vendor/bin/pest
# Parallel execution
./vendor/bin/pest --parallel
# Filter by name
./vendor/bin/pest --filter "user can"
# Coverage
./vendor/bin/pest --coverage --min=80
# Profile slow tests
./vendor/bin/pest --profile
RefreshDatabase trait