After hunting around Google and Github without finding a clear way to assert the values returned from Inertia::render
the same way you can with a blade view, assertViewHas
, I realized Inertia is returning a $page
variable with the props. Because of this, we can drill down to the value we want to assert since assertViewHas
accepts dot notation.
Post::factory(10)->create();
$this->get('/posts')
->assertViewHas('page.props.posts.data', function($posts) {
return count($posts) == 10;
});
Note: Im paginating $posts, otherwise .data
is not needed
Top comments (0)