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...