Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Debugging with dd() and dump()

Premium
2 min read

I want to show you a few helper methods for debugging your failed HTTP tests.


Imagine the scenario in which you want to assert the Forbidden status. But instead of getting an error Expected response status code [403] but received 200., you receive a normal status 200. It could mean there's a Middleware problem or wrong permissions added.

But what is inside that 200, and how does that page actually look? How do you debug those internal parts?

In the test, you load the page and call assertForbidden(), so you don't see the actual response's content.

use function Pest\Laravel\actingAs;
 
beforeEach(function (): void {
$this->user = User::factory()->create();
});
 
test('guest cannot access products page', function () {
actingAs($this->user)
->get('/products/create')
->assertForbidden();
});

You can use the dd() method on...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (31 h 16 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

No comments yet…