laravel-tdd

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

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill laravel-tdd-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-tdd
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/laravel-tdd
Command: npx skills add https://github.com/ibytechaos/claude --skill laravel-tdd-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Laravel tests requires choosing the right framework, database strategy, and faking approach, and this Skill provides a structured TDD workflow so tests are consistent, isolated, and maintainable. ## Core Features & Use Cases - Red-Green-Refactor Workflow: Applies the TDD cycle across unit, feature, and integration test layers with guidance on when to use each. - Database Testing Strategies: Covers RefreshDatabase, DatabaseTransactions, and DatabaseMigrations with clear selection criteria for each. - Fakes and Isolation: Demonstrates Bus, Queue, Mail, Notification, Event, and Http fakes plus Sanctum auth and Inertia assertions. - Use Case: When adding a new API endpoint to a Laravel app, use this Skill to write a failing Pest feature test first, implement the minimal controller logic, and verify with factories and assertDatabaseHas. ## Quick Start Write a failing Pest feature test for a new Laravel API 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 TDD tests for a Laravel API endpoint?

Write a failing feature test first using actingAs and postJson, then implement the minimal controller code to pass. Use factories for test data and assertDatabaseHas to verify persistence, following the red-green-refactor cycle.

Should I use Pest or PHPUnit for Laravel testing?

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.

What is the difference between RefreshDatabase and DatabaseTransactions in Laravel?

RefreshDatabase runs migrations once per test run and wraps each test in a transaction when supported, making it the default choice. DatabaseTransactions only rolls back per test and suits already-migrated schemas, while in-memory SQLite re-migrates per test.

How do I test queued jobs and notifications in Laravel?

Use Queue::fake() with Queue::assertPushed() for jobs and Notification::fake() with Notification::assertSentTo() for notifications. These fakes prevent actual side effects while letting you assert the correct dispatches occurred.

How do I test Laravel Inertia pages?

Use the assertInertia method with AssertableInertia to check the component name and props, such as ->component('Dashboard')->where('user.id', $user->id). This keeps tests aligned with Inertia responses rather than raw JSON.