Livewire Testing: Undefined array key "fingerprint" Error

Recently I've been using Filament CMS quite a lot. It makes use of Livewire through out and as with any new technology I've been exploring what it can do.

While writing a component test I ran into a cryptic error. The usual Google-the-problem approach didn't work!

The test

<?php

use function Pest\Livewire\livewire;

test('Component can be filled', function (): void {
    livewire(Component::class)
        ->fillForm([
            // ...
        ]);
});

The error:

Undefined array key "fingerprint" at vendor/livewire/livewire/src/Testing/TestableLivewire.php:206

After not being able to easily find the answer I moved on to trying other things. The lightbulb light up when I got a Expected response status code [>=200, <300] but received 403. in another test. No user is logged-in!

Sure enough once I added auth the test passes:

<?php

use function Pest\Livewire\livewire;

test('Component can be filled', function (): void {
    $this->actingAs(User::factory()->create());

    livewire(Component::class)
        ->fillForm([
            // ...
        ]);
});

I don't (yet) understand Livewire well enough to know why this error is thrown rather than a more intuitive Authorisation Exception.

Popular Reads

Subscribe

Keep up to date

Please provide your email address
Please provide your name
Please provide your name
No thanks