DEV Community


Laravel Assert Inertia Values

im brian d
Hi, I'm Brian D. I am a full stack developer. I build apps using the Laravel php backend framework and vue.js frontend framework.
・1 min read

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.


    ->assertViewHas('', function($posts) {
        return count($posts) == 10;
Enter fullscreen mode Exit fullscreen mode

Note: Im paginating $posts, otherwise .data is not needed

Discussion (0)