Testing helpers for

helpers, testing, phpunit, laravel, inertia, claudiodekker


inertiajs/inertia-laravel Testing Helpers

NOTE: This package WILL be deprecated once ANY official testing helpers become available in inertiajs/inertia-laravel. The package WILL stay available for install, but WILL NOT receive any further (security) updates from that point forward.

Latest Version Build Status Quality Score StyleCI Total Downloads


You can install the package via composer:

composer require claudiodekker/inertia-laravel-testing


To test, simply chain any of the following methods onto your TestResponse responses.

Screenshot 2020-09-02 at 19 44 39

Available Methods

The methods made available in this package closely reflect those available in Laravel itself:

Assert whether the given page is an Inertia-rendered view


// or, also check whether the page is a specific component

// or, also check whether all of the given props match
$response->assertInertia('example', [
    'foo' => 'bar'

Return all available Inertia props for the page, or only retrieve a specific one


// Retrieve a specific (nested) prop. Returns `null` if the prop doesn't exist.

Assert whether the Inertia-rendered view has a specific property set


// or, against deeply nested values

Apart from checking whether the property is set, the same method can be used to assert that the values match

$response->assertInertiaHas('key', 'matches-this-value');

// or, for deeply nested values
$response->assertInertiaHas('deeply.nested.key', 'also-match-against-this-value');

It's also possible to assert directly against a Laravel Model (or any other Arrayable or Responsable class)

$user = UserFactory::new()->create(['name' => 'John Doe']);

// ... (Make HTTP request etc.)

$response->assertInertiaHas('user', $user);
$response->assertInertiaHas('deeply.nested.user', $user);

It's also possible to check against a closure

$response->assertInertiaHas('foo', function ($value) {
    return $value === 'bar';

// or, again, for deeply nested values
$response->assertInertiaHas('', function ($value) {
    return $value === 'bar';

Next, you can also check against a whole array of properties. It'll simply loop over them using the assertInertiaHas method described above:

    'another.nested.key' => 'example-value'

Finally, you can assert that a property was not set:


// or, for deeply nested values


composer test


Please see CHANGELOG for more information what has changed recently.


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.


The MIT License (MIT). Please see License File for more information.