laravel-testing-lord
Lord skill for Laravel 13 + Filament v5 testing mastery — Pest 3+, feature tests, Filament resource tests, API tests, database tests, and CI/CD.
SKILL.mdskills/laravel-testing-lord/SKILL.md
GitHubLaravel Testing Lord
[OBJ] Mastery of testing for Laravel 13 + Filament v5 — Pest 3+, feature tests, Filament resource tests, API tests, database tests, and CI/CD integration.
[RULES]
- [CMD] Query Context7 for Pest 3+ and Laravel testing docs. Use
/pestphp/pestand/laravel/frameworklibrary IDs. - [REQ] Pest 3+: Use Pest 3+ for all backend tests.
describe()blocks for grouping.it()for test cases. AAA pattern (Arrange-Act-Assert). One behavior per test. - [REQ] Two-Tier Testing: FAST tier —
artisan test --filter=<test>(~5s, during iteration). FULL tier —artisan test(complete suite + coverage, before done). NEVER run full suite on every change. - [REQ] Filament Resource Tests: Use
Filament\Tables\Tabletesting helpers.->canSeeRecord()/->cannotSeeRecord(). TestActionvisibility via policy. Test form validation via->fillForm()+->assertHasFormErrors(). - [REQ] API Tests:
->assertJsonStructure(Resource::JSON_STRUCTURE)for response shape.->assertJsonPath()for specific values. Test all CRUD operations. Test API versioning viaX-Api-Versionheader. NEVER test without authentication context. - [REQ] Database Tests:
RefreshDatabasetrait for test isolation.Database\Factoriesfor test data. NEVER hardcoded IDs or dates. UseModel::factory()->create()for test data. Test constraints (foreign keys, unique, not null). - [REQ] Coverage: 80% logic, 90% API, 70% total. Use
--coveragein FULL tier.XDEBUG_MODE=coveragefor accurate coverage. NEVER declare done without coverage report. - [REQ] Parallel Testing:
artisan test --parallel --exclude-group=serialfor fast parallel.--group=serialfor tests that can't run in parallel (shared state, migrations). SQLite for fast tier, MySQL/PG for FULL tier. - [REQ] Mocking: Mock external services (
Http::fake(),Queue::fake(),Event::fake()). UseFakePlusLicenseServicepattern for swappable implementations. NEVER mock Eloquent models — use factories + in-memory DB. - [REQ] Vector Search Tests: Test
whereVectorSimilarTo()with known embeddings. TestAsVectorcast round-trip (set array → get array). Test MariaDB binary format vs PG JSON text. Mock embedding API in tests. - [REQ] Security Tests: Test authorization (policy gates) on every resource action. Test input validation (FormRequest). Test SQL injection prevention. Test XSS prevention. Test CSRF tokens. NEVER skip auth tests.
- [REQ] Browser Testing:
pestphp/pest-plugin-browserfor E2E. Test critical user flows (login, CRUD, admin panel). UseLaravel\Duskfor JavaScript-dependent tests. NEVER rely only on unit tests for UI. - [REQ] CI/CD: Run FULL tier in CI.
--parallelfor speed. Upload coverage report. Fail on < 70% total. NEVER merge without green CI.
[WORKFLOWS]
- Test a Filament Resource: Create
tests/Filament/Resources/UserResourceTest.php→ test list (->canSeeRecord()) → test create (->fillForm()->call('create')->assertHasNoFormErrors()) → test edit → test delete → test policy (->cannotSeeRecord()for unauthorized user) → test validation (->fillForm(['email' => 'invalid'])->assertHasFormErrors(['email'])). - Test an API Endpoint: Create
tests/Feature/Api/UserApiTest.php→ test index (->getJson('/api/users')->assertJsonStructure(UserResource::JSON_STRUCTURE)) → test store → test show → test update → test destroy → test auth (->actingAs($user)) → test validation → test versioning (->withHeader('X-Api-Version', '2')). - Test Vector Search: Create
tests/Feature/VectorSearchTest.php→ seed known embeddings → testwhereVectorSimilarTo()returns correct order → testAsVectorcast → test distance threshold → test with MariaDB binary format → mock embedding API.