laravel-testing

Enforce Laravel testing best practices with Pest PHP and PHPUnit.

1|Updated Feb 28, 2026
One-click install
npx skills add https://github.com/sasabajic/laravel-best-practice-skills --skill laravel-testing-sasabajic
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-testing
Source: https://github.com/sasabajic/laravel-best-practice-skills/tree/main/laravel-testing
Command: npx skills add https://github.com/sasabajic/laravel-best-practice-skills --skill laravel-testing-sasabajic

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a comprehensive guide and best practices for writing effective tests in Laravel applications, ensuring code quality and reliability.

Core Features & Use Cases

  • Pest PHP Integration: Leverage Pest for cleaner, more expressive test syntax.
  • Test Organization: Structure tests logically into Feature and Unit directories.
  • Comprehensive Coverage: Includes examples for API testing, model factories, fakes, and more.
  • Use Case: Ensure your new API endpoint for order creation is thoroughly tested for success, validation errors, and authorization failures.

Quick Start

Write a feature test for the /api/v1/orders endpoint using Pest PHP.

Frequently Asked Questions about laravel-testing

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

FAQPage Schema
How do I write a feature test for a Laravel API endpoint?

Laravel feature testing involves structuring tests in Feature directories and using model factories to verify API endpoints. This approach validates success responses, validation errors, and authorization rules effectively.

What is the best way to organize Laravel tests using Pest PHP?

Organizing Laravel tests involves splitting them into Feature and Unit directories while leveraging Pest PHP for cleaner syntax. This structure ensures logical grouping and optimizes overall test execution.

How does LazilyRefreshDatabase optimize Laravel test execution speed?

LazilyRefreshDatabase optimizes test speed by refreshing the database only when a test actually requires it. This trait reduces unnecessary migrations, significantly speeding up Laravel test execution.

Can I use PHPUnit for database testing and mocking in Laravel?

PHPUnit fully supports database testing and mocking in Laravel by utilizing model factories for data creation and applying mocks to isolate components. This ensures reliable and isolated test assertions.

Does this Laravel testing approach support TDD workflows?

This approach fully supports TDD workflows in Laravel by enabling you to write feature and unit tests using Pest PHP or PHPUnit before implementation. This ensures reliable, test-driven code quality.

When should I use model factories in Laravel unit testing?

Use model factories in Laravel unit testing to generate fake data for database assertions and state checks. They provide consistent, isolated test data, ensuring reliable database testing without manual setup.