Write tests with Pest 3/PHPUnit, feature tests, unit tests, mocking, fakes, and factories. Use when testing controllers, services, models, or implementing TDD.
View on GitHubFebruary 2, 2026
Select agents to install to:
npx add-skill https://github.com/fusengine/agents/blob/main/plugins/laravel-expert/skills/laravel-testing/SKILL.md -a claude-code --skill laravel-testingInstallation paths:
.claude/skills/laravel-testing/# Laravel Testing ## Agent Workflow (MANDATORY) Before ANY implementation, launch in parallel: 1. **fuse-ai-pilot:explore-codebase** - Analyze existing test patterns 2. **fuse-ai-pilot:research-expert** - Verify Pest/PHPUnit docs via Context7 3. **mcp__context7__query-docs** - Check assertion and mocking patterns After implementation, run **fuse-ai-pilot:sniper** for validation. --- ## Overview | Type | Purpose | Location | |------|---------|----------| | **Feature** | HTTP, full stack | `tests/Feature/` | | **Unit** | Isolated classes | `tests/Unit/` | | **Arch** | Code architecture | `tests/Arch.php` | --- ## Decision Guide: Test Type ``` 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() ``` --- ## Decision Guide: Test Strategy ``` Coverage strategy? ├── Feature tests (70%) → Critical flows ├── Unit tests (25%) → Business logic ├── E2E tests (5%) → User journeys └── Arch tests → Structural rules ``` --- ## Critical Rules 1. **Use RefreshDatabase** for database isolation 2. **Use factories** for test data (never raw inserts) 3. **Mock external services** - Never call real APIs 4. **Test edge cases** - Empty, null, boundaries 5. **Run parallel** - `pest --parallel` for speed --- ## Reference Guide ### Pest Basics | Topic | Reference | When to Consult | |-------|-----------|-----------------| | **Pest Syntax** | [pest-basics.md](references/pest-basics.md) | it(), test(), describe() | | **Datasets** | [pest-datasets.md](references/pest-datasets.md) | Data providers, hooks | | **Architecture** | [pest-arch.md](references/pest-arch.md) | arch() tests | ### HTTP Testing | Topic | Reference | When to Consult | |-------|-----------|-----------------| | **Requests** | [http-requests.md](references/http-requests.md) | GET, POST, headers | | **JSON API** | [http-json.md](refer