Apply `RefreshDatabase` to the Pest file or shared test setup: ```php use Illuminate\Foundation\Testing\RefreshDatabase; uses(RefreshDatabase::class); it('stores a post', function () { Post::factory()->create(); expect(Post::count())->toBe(1); }); ``` Laravel migrates the test database and resets it between tests, preventing state leakage. Use `DatabaseTransactions` when transaction rollback is sufficient and faster, but choose `RefreshDatabase` for tests that need a clean schema/database lif...
Installs into .claude/skills of the current project.
Are you the author of Laravel Testing?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-laravel-testing-d2e42274)
Apply `RefreshDatabase` to the Pest file or shared test setup:
```php
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('stores a post', function () {
Post::factory()->create();
expect(Post::count())->toBe(1);
});
```
Laravel migrates the test database and resets it between tests, preventing state leakage. Use `DatabaseTransactions` when transaction rollback is sufficient and faster, but choose `RefreshDatabase` for tests that need a clean schema/database lifecycle. Keep test data in factories rather than raw table inserts and configure the test connection explicitly, commonly SQLite with `:memory:`.