Skip to main content
You are currently viewing the documentation for Filament 3.x, which is a previous version of Filament.Looking for the current stable version? Visit the 5.x documentation.

Overview

All examples in this guide will be written using Pest. To use Pest’s Livewire plugin for testing, you can follow the installation instructions in the Pest documentation on plugins: Livewire plugin for Pest. However, you can easily adapt this to PHPUnit. Since all actions are mounted to a Livewire component, we’re just using Livewire testing helpers everywhere. If you’ve never tested Livewire components before, please read this guide from the Livewire docs.

Getting started

You can call an action by passing its name or class to callAction():
To pass an array of data into an action, use the data parameter:
If you ever need to only set an action’s data without immediately calling it, you can use setActionData():

Execution

To check if an action has been halted, you can use assertActionHalted():
To assert the content of a modal, you should first mount the action (rather than call it which closes the modal). You can then use Livewire assertions such as assertSee() to assert the modal contains the content that you expect it to:

Errors

assertHasNoActionErrors() is used to assert that no validation errors occurred when submitting the action form. To check if a validation error has occurred with the data, use assertHasActionErrors(), similar to assertHasErrors() in Livewire:
To check if an action is pre-filled with data, you can use the assertActionDataSet() method:

Action state

To ensure that an action exists or doesn’t, you can use the assertActionExists() or assertActionDoesNotExist() method:
To ensure an action is hidden or visible for a user, you can use the assertActionHidden() or assertActionVisible() methods:
To ensure an action is enabled or disabled for a user, you can use the assertActionEnabled() or assertActionDisabled() methods:
To ensure sets of actions exist in the correct order, you can use assertActionsExistInOrder():
To check if an action is hidden to a user, you can use the assertActionHidden() method:

Button appearance

To ensure an action has the correct label, you can use assertActionHasLabel() and assertActionDoesNotHaveLabel():
To ensure an action’s button is showing the correct icon, you can use assertActionHasIcon() or assertActionDoesNotHaveIcon():
To ensure that an action’s button is displaying the right color, you can use assertActionHasColor() or assertActionDoesNotHaveColor():

URL

To ensure an action has the correct URL, you can use assertActionHasUrl(), assertActionDoesNotHaveUrl(), assertActionShouldOpenUrlInNewTab(), and assertActionShouldNotOpenUrlInNewTab():