Laravel Pest feature test for an API endpoint with a factory
PHP Dasun Kalupahana 70 views
<?php
it('creates a post', function () {
$user = User::factory()->create();
$this->actingAs($user)
->postJson('/api/posts', ['title' => 'Hello'])
->assertCreated()
->assertJsonPath('data.title', 'Hello');
$this->assertDatabaseHas('posts', ['title' => 'Hello']);
});
Tests that an endpoint creates a record and returns the right JSON. Pest is the default test runner in new Laravel apps.
Learn more on the blog
MySQL
PostgreSQL vs MySQL Performance: Real Benchmarks Compared
Last updated: 7 November 2026. See the update log at the end."Which...
8 min read
PHP
How to Detect and Fix PHP Memory Leaks
Last updated: 5 November 2026. See the update log at the end.In...
9 min read
Docker
Docker Build Too Slow? 10 Ways to Speed It Up
A slow Docker build usually has one of a few causes: you...
8 min read