laravel-tdd
Test-driven development for Laravel with PHPUnit and Pest, factories, database testing, fakes, and coverage targets.
Security Assessment
About laravel-tdd
The 'laravel-tdd' skill is designed to facilitate test-driven development (TDD) in Laravel applications, leveraging PHPUnit and Pest as primary testing frameworks. It addresses common challenges in ensuring code reliability and maintainability by providing a structured approach to writing, executing, and refactoring tests. This skill helps developers enforce rigorous testing practices, such as maintaining high test coverage across unit, feature, and integration layers, and encourages early detection of defects by promoting the red-green-refactor cycle. By doing so, it reduces bugs in production, ensures consistent behavior, and improves confidence when making changes or adding new features to Laravel projects.
Key features of this skill include support for various test layers (unit, feature, integration), database testing strategies (RefreshDatabase, DatabaseTransactions, DatabaseMigrations), and framework selection guidance between PHPUnit and Pest. It emphasizes the use of factories for generating test data, fakes for simulating external dependencies, and maintaining at least 80% code coverage across tests. The skill provides explicit recommendations on when to use each type of test, how to structure them, and includes practical examples in both PHPUnit and Pest to illustrate typical workflows for creating, executing, and asserting tests. Additionally, it outlines best practices for database handling to ensure tests remain isolated and repeatable.
This skill is particularly suited for Laravel developers working on new features, endpoints, or refactoring existing code. It is valuable for teams aiming to enforce consistent testing standards, maintain high test coverage, and improve code quality. Use cases include testing Eloquent models, HTTP endpoints, authentication flows, validation rules, policies, jobs, and notifications. Both individual developers and collaborative teams can benefit, especially when introducing Pest into projects for more expressive testing syntax while retaining compatibility with existing PHPUnit setups.
FAQ
When should I use Pest versus PHPUnit for testing?
Use Pest for new tests if the project supports it, as it provides a concise syntax and modern testing experience. Use PHPUnit only if the project already standardizes on it or requires PHPUnit-specific tooling.
Which database strategy should I choose for feature tests?
Use 'RefreshDatabase' as the default for tests touching the database. It wraps each test in a transaction where supported, and re-migrates for in-memory or non-transactional databases. 'DatabaseTransactions' is suitable when the schema is already migrated, and 'DatabaseMigrations' is used when a full fresh migration per test is required.
Can this skill be used for integration testing with queues and external services?
Yes, integration tests are supported and intended for scenarios that validate interactions between the database, queues, and external services together.
Is there a recommended coverage target for tests?
The skill recommends maintaining 80% or higher coverage across unit and feature tests to ensure sufficient test reliability.
What types of Laravel components are ideal for testing with this skill?
You can test Eloquent models, policies, jobs, notifications, HTTP endpoints, authentication flows, and validation logic, with the choice of test layer guiding how isolated or comprehensive the test should be.
Install laravel-tdd
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
affaan-m/everything-claude-code