How to test logic inside Inertia::lazy()
On my Controller, I am returning some products using Inertia::lazy() like so:
return Inertia::render('SomePage', [
'products' => Inertia::lazy(function () {
// Some logic here to fetch products
})
]);
What is the approach to test that everything goes well inside the lazy function?
Using $response->assertStatus(200) only tests the stuff outside that function, right?
I found a solution:
$response = $this->withHeaders([
"x-inertia-partial-component" => [ "SomePage" ],
"x-inertia" => [ true ],
"x-inertia-partial-data" => [ 'products' ]
])
->get('some-route')
;
$response->assertStatus(200);
$this->assertObjectHasAttribute('products', $response->getData()->props);
Please or to participate in this conversation.