laravel-tdd

Implements test-driven development for Laravel applications using PHPUnit and Pest.

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/Femad-6/my-skills --skill laravel-tdd-femad-6
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-tdd
Source: https://github.com/Femad-6/my-skills/tree/main/.github/skills/laravel-tdd
Command: npx skills add https://github.com/Femad-6/my-skills --skill laravel-tdd-femad-6

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Laravel tests requires choosing the right framework, database strategy, and isolation techniques, and mistakes lead to slow, flaky, or incomplete test suites. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Guides the full TDD cycle across unit, feature, and integration test layers. - Database Testing Strategies: Selects between RefreshDatabase, DatabaseTransactions, and DatabaseMigrations based on schema and performance needs. - Fakes and Isolation: Uses Bus, Queue, Mail, Notification, Event, and Http fakes to test side effects without external dependencies. - Use Case: When adding a new API endpoint, write a failing Pest feature test with factories and Sanctum auth, implement the minimal controller logic, then refactor while keeping 80%+ coverage. ## Quick Start Write a failing Pest feature test for a new Laravel endpoint that creates a project, then implement the minimal code to make it pass.

Frequently Asked Questions about laravel-tdd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write feature tests for Laravel API endpoints?

Use PHPUnit or Pest with RefreshDatabase, create test data via factories, authenticate with actingAs or Sanctum::actingAs, then assert on response status and JSON structure. Verify persistence with assertDatabaseHas.

Pest vs PHPUnit for Laravel testing, which should I use?

Default to Pest for new tests when available, as it offers a more expressive syntax. Use PHPUnit only if the project already standardizes on it or requires PHPUnit-specific tooling.

When should I use RefreshDatabase vs DatabaseTransactions in Laravel?

Use RefreshDatabase as the default for tests touching the database; it migrates once per run and wraps tests in transactions. Use DatabaseTransactions when the schema is already migrated and you only need per-test rollbacks.

How do I test queued jobs and notifications in Laravel?

Use Queue::fake() and Notification::fake() to isolate side effects, then assert with Queue::assertPushed() and Notification::assertSentTo(). Similar fakes exist for Bus, Mail, and Event.

How do I test Inertia.js pages in Laravel?

Use the assertInertia method with AssertableInertia to verify the component name and props, such as checking the component is Dashboard and the user.id prop matches. Prefer this over raw JSON assertions.