- Home
- Skills
- Anilcancakir
- My Claude Code
- Laravel Testing
laravel-testing_skill
4
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill anilcancakir/my-claude-code --skill laravel-testing- SKILL.md5.8 KB
Overview
This skill provides practical Laravel testing patterns using PHPUnit and Dusk for Laravel 12+. It covers feature, unit, and browser tests plus factories, common assertions, and mocking approaches to keep tests reliable and maintainable. Always active for test-related contexts, CI runs, and TDD workflows.
How this skill works
The skill inspects test files and runtime signals to offer targeted guidance: it recognizes tests/Feature, tests/Unit, tests/Browser, php artisan test runs, and common failure triggers. It suggests assertions, factory usage, RefreshDatabase patterns, mocking examples, and Dusk troubleshooting (missing elements, screenshots). It also proposes command-line and coverage options for CI and local workflows.
When to use it
- Writing or updating tests (unit, feature, browser)
- Running php artisan test or CI test pipelines
- When a test fails or an assertion error appears
- When using factories, RefreshDatabase, actingAs, or mocks
- When Dusk element not found, screenshot, or browser test issues occur
Best practices
- Use RefreshDatabase trait for isolated DB state in feature tests
- Prefer factories and states for realistic fixtures instead of manual seed data
- Assert HTTP response codes and JSON structure to verify contract stability
- Mock external services (payment, mail) to make tests deterministic
- Use Dusk screenshots and waitFor* helpers for flaky browser tests
Example use cases
- Feature test: actingAs a user and asserting response codes, JSON structure, and database row
- Unit test: instantiate service classes and assert pure calculation outputs
- Factory usage: create related models with ->for() and ->has() to seed complex relationships
- Mocking: replace PaymentService in tests to verify charge logic without external calls
- Dusk: find element failures -> capture screenshot and use ->waitFor() or CSS selectors to stabilize tests
FAQ
Use in-memory SQLite when possible or RefreshDatabase to reset state. For heavy suites, run php artisan test --parallel to leverage multiple processes.
What to do when Dusk reports element not found?
Capture a screenshot, verify selectors and waiting strategy, and prefer waitFor* or explicit pauses for dynamic content. Ensure the element is visible and not in a different frame or shadow DOM.