0090-laravel-testing

Write Pest tests for Laravel actions using Arrange-Act-Assert and declarative factories.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0090-laravel-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: 0090-laravel-testing
Source: https://github.com/MrJmpl3/codex_____data_____configuration/tree/main/skills/0090-laravel-testing
Command: npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0090-laravel-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you avoid brittle, slow, and confusing Laravel tests by standardizing how you arrange data, perform actions, and assert outcomes with Pest.

Core Features & Use Cases

  • Arrange-Act-Assert discipline to keep tests focused, readable, and resilient to refactors.
  • Mocking patterns that don’t break: mock only what you own, swap dependencies in the container, and verify arguments safely.
  • Null driver strategy to create deterministic, fast tests without external services.
  • Declarative factories for intent-first data so tests don’t leak database schema details.
  • Testing approach by layer: feature tests for HTTP cycles and unit/action tests for domain logic isolation.

Quick Start

Use the 0090-laravel-testing skill when you need to write a new Pest test for a Laravel action and want it to follow Arrange-Act-Assert with declarative factories.

Frequently Asked Questions about 0090-laravel-testing

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

FAQPage Schema
How do I write reliable Pest tests for Laravel actions?

To write reliable Pest tests for Laravel actions, structure your test using Arrange-Act-Assert discipline, generate data with declarative factories, and isolate domain logic from HTTP cycles. This keeps tests focused, readable, and resilient to refactors.

What is the best way to mock dependencies in Laravel Pest tests?

The best way to mock dependencies in Laravel Pest tests is to mock only what you own, swap the mocked collaborators into the container using resolve() and swap(), and use behavior-focused assertions. This approach reduces test brittleness and prevents external service failures.

How do I create deterministic Laravel tests without external dependencies?

You can create deterministic Laravel tests without external dependencies by applying the null driver strategy. This pattern allows you to build fast, predictable tests by replacing external services with a null driver, ensuring your test outcomes remain consistent.

How does Arrange-Act-Assert improve Laravel feature testing?

Arrange-Act-Assert improves Laravel feature testing by separating data setup, action execution, and outcome verification into distinct phases. This discipline enforces focused, readable tests and validates database state transitions and request/response behavior clearly.

When should I use declarative factories instead of raw database inserts in Pest tests?

You should use declarative factories instead of raw database inserts when you want intent-first data that does not leak database schema details. Factories keep your Pest tests maintainable and focused on the domain logic rather than underlying table structures.

Can I use Pest testing patterns for both unit and feature tests in Laravel?

Yes, you can use Pest testing patterns for both unit and feature tests in Laravel. Use feature tests for complete HTTP cycles and unit or action tests to isolate domain logic, applying container-based resolution and mocking to maintain clean separation.