Skip to content

Instantly share code, notes, and snippets.

@jasonlbeggs
Created March 5, 2021 23:22
Show Gist options
  • Save jasonlbeggs/b0772467839b3e75b2b7e0513c1d8d35 to your computer and use it in GitHub Desktop.
Save jasonlbeggs/b0772467839b3e75b2b7e0513c1d8d35 to your computer and use it in GitHub Desktop.

Livewire Test Debugging Tips

If you're testing a Livewire component and need to debug validation errors, the last response, the last rendered view, etc., Livewire offers these public properties on the tested component. I find dumping the lastErrorBag handy pretty often!

/** @test */
public method something_works()
{
    $component = Livewire::test(SomeComponent::class)->call('someMethod');
    
    dd(
        $component->lastValidator,
        $component->lastErrorBag,
        $component->lastResponse,
        $component->lastRenderedView,
        $component->lastRenderedDom,
    );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment