What does this skill do?

The Laravel TDD Master Skill guides you through a complete Test-Driven Development (TDD) workflow for Laravel applications, covering initial setup, Eloquent factories, HTTP testing with Sanctum, and simulating external services. It follows the RED-GREEN-REFACTOR cycle and checks code coverage to ensure robust, error-free applications.

New Features
Develop new features or apps from scratch following the strict RED-GREEN-REFACTOR TDD cycle.
APIs with Sanctum
Implement and test endpoints authenticated with Sanctum or Passport, including JSON assertions.
Factories and Models
Create factories with custom states and test Eloquent scopes, relationships, and accessors.
Service mocks
Simulate queues, emails, notifications, and external HTTP requests using Http::fake, Mail::fake, and Queue::fake.

Usage examples

🧪 Model Test
Write a unit test for the `admin` scope of the `User` model using factories, and then implement the minimum amount of code needed to make it pass.
🔐 API with Sanctum
Create a feature test for the login endpoint using Sanctum authentication, and then implement the controller.
🎭 Stripe Mock
Simulate the Stripe API using Http::fake and test the PaymentService with a successful payment response.
⚙️ Initial Setup
Configure phpunit.xml to use in-memory SQLite and disable email and the queue in the test environment.

Features

Complete TDD Cycle Follow the RED-GREEN-REFACTOR workflow with PHPUnit or Pest, writing the failing test first.
Eloquent Factories Create factories with custom states such as admin() or unverified() to isolate test data.
Authenticated API Tests Implement and test endpoints using Sanctum or Passport, including JSON response assertions.
Mocks of External Services Isolate modules using Http::fake, Mail::fake, Queue::fake, and Notification::fake.
Code Coverage Generate coverage metrics with configurable targets (e.g., 80% overall, 95% in models).

Frequently asked questions

Both are compatible. The skill works with PHPUnit and Pest, adapting the syntax based on the framework you use.
It works with Laravel 8 or later that includes Sanctum and the current Eloquent factory system.
Yes. The skill includes setting up test infrastructure for existing Laravel projects.
Running the tests with coverage flags such as --coverage-html and adjusting them according to the targets defined per model or globally.
Laravel TDD Master — Robust TDD Testing with Claude AI

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.