About laravel-controller-tests
A skill for writing Laravel controller feature tests and improving their structure. It recommends testing validation through Form Requests, business logic through Actions, and using factories instead of heavy mocking.
Key features
- 01Write endpoint feature tests
- 02Assert validation errors
- 03Test Form Requests directly
- 04Unit test extracted Actions
- 05Use factories instead of heavy mocking
Use cases
- 01Test that an endpoint rejects invalid input
- 02Verify validation through a Form Request
- 03Test business logic separately from a controller
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ noartem/ skills --skill laravel-controller-testsAfter installing, type/laravel-controller-testsin Claude Code to confirm it loaded.
Details
From the project READMEController Tests
Feature tests for endpoints
it('rejects empty email', function () {
$this->post('/register', ['email' => ''])->assertSessionHasErrors('email');
});
Better tests
- Move validation to Form Requests; assert errors from the request class
- Extract business logic into Actions; unit test them directly
- Use factories for realistic data; avoid heavy mocking
Comments
Markdown supported