Skip to main content

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

Read more here

Disable Exception Handling

Premium
3 min read

Let's look at another trick: how to view the test errors slightly differently.


The Problem

Imagine you have a test to check if the record is being seen on the page.

use App\Models\User;
use App\Models\Product;
use function Pest\Laravel\actingAs;
 
beforeEach(function (): void {
$this->user = User::factory()->create();
});
 
test('homepage contains table product', function () {
$product = Product::create([
'name' => 'table',
'price' => 100,
]);
 
actingAs($this->user)
->get('/products')
->assertOk()
->assertSeeText($product->name);
});

In the Controller, you left a typo for the variable.

use App\Models\Product;
use Illuminate\View\View;
 
class ProductController extends Controller
{
public function index(): View
{
$product = Product::all();
 
return view('products.index', compact('products'));
}
}

When you run the test, it gives...

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…