Skip to main content
You are currently viewing the documentation for Filament 2.x, which is a previous version of Filament.Looking for the current stable version? Visit the 5.x documentation.
All examples in this guide will be written using Pest. However, you can easily adapt this to PHPUnit. Since the table builder works on Livewire components, you can use the Livewire testing helpers. However, we have many custom testing helpers that you can use for tables:

Render

To ensure a table component renders, use the assertSuccessful() Livewire helper:
To to test which records are shown, you can use assertCanSeeTableRecords(), assertCanNotSeeTableRecords() and assertCountTableRecords():
Note that if your table uses pagination, assertCanSeeTableRecords() will only check for records on the first page. To switch page, call set('page', 2).
Note that if your table uses deferLoading(), you should call loadTable() before assertCanSeeTableRecords().

Columns

To ensure that a certain column is rendered, pass the column name to assertCanRenderTableColumn():
This helper will get the HTML for this column, and check that it is present in the table. For testing that a column is not rendered, you can use assertCanNotRenderTableColumn():
This helper will assert that the HTML for this column, is not shown by default in the present table.

Sorting

To sort table records, you can call sortTable(), passing the name of the column to sort by. You can use 'desc' in the second parameter of sortTable() to reverse the sorting direction. Once the table is sorted, you can ensure that the table records are rendered in order using assertCanSeeTableRecords() with the inOrder parameter:

Searching

To search the table, call the searchTable() method with your search query. You can then use assertCanSeeTableRecords() to check your filtered table records, and use assertCanNotSeeTableRecords() to assert that some records are no longer in the table:
To search individual columns, you can pass an array of searches to searchTableColumns():

State

To assert that a certain column has a state or does not have a state for a record you can use assertTableColumnStateSet() and assertTableColumnStateNotSet():
To assert that a certain column has a formatted state or does not have a formatted state for a record you can use assertTableColumnFormattedStateSet() and assertTableColumnFormattedStateNotSet():

Existence

To ensure that a column exists, you can use the assertTableColumnExists() method:

Authorization

To ensure that a particular user cannot see a column, you can use the assertTableColumnVisible() and assertTableColumnHidden() methods:

Descriptions

To ensure a column has the correct description above or below you can use the assertTableColumnHasDescription() and assertTableColumnDoesNotHaveDescription() methods:

Extra Attributes

To ensure that a column has the correct extra attributes you can use the assertTableColumnHasExtraAttributes() and assertTableColumnDoesNotHaveExtraAttributes() methods:

Select Columns

If you have a select column, you can ensure it has the correct options with assertSelectColumnHasOptions() and assertSelectColumnDoesNotHaveOptions():

Filters

To filter the table records, you can use the filterTable() method, along with assertCanSeeTableRecords() and assertCanNotSeeTableRecords():
For a simple filter, this will just enable the filter. If you’d like to set the value of a SelectFilter or TernaryFilter, pass the value as a second argument:

Resetting filters

To reset all filters to their original state, call resetTableFilters():

Removing Filters

To remove a single filter you can use removeTableFilter():
To remove all filters you can use removeTableFilters():

Actions

Calling actions

You can call an action by passing its name or class to callTableAction():
This example assumes that you have a DeleteAction on your table. If you have a custom Action::make('reorder'), you may use callTableAction('reorder'). For column actions, you may do the same, using callTableColumnAction():
For bulk actions, you may do the same, passing in multiple records to execute the bulk action against with callTableBulkAction():
To pass an array of data into an action, use the data parameter:

Execution

To check if an action or bulk action has been halted, you can use assertTableActionHalted() / assertTableBulkActionHalted():

Errors

assertHasNoTableActionErrors() 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 assertHasTableActionErrors(), similar to assertHasErrors() in Livewire:
For bulk actions these methods are called assertHasTableBulkActionErrors() and assertHasNoTableBulkActionErrors().

Pre-filled data

To check if an action or bulk action is pre-filled with data, you can use the assertTableActionDataSet() or assertTableBulkActionDataSet() method:

Action state

To ensure that an action or bulk action exists or doesn’t in a table, you can use the assertTableActionExists() / assertTableActionDoesNotExist() or assertTableBulkActionExists() / assertTableBulkActionDoesNotExist() method:
To ensure different sets of actions exist in the correct order, you can use the various “InOrder” assertions
To ensure that an action or bulk action is enabled or disabled for a user, you can use the assertTableActionEnabled() / assertTableActionDisabled() or assertTableBulkActionEnabled() / assertTableBulkActionDisabled() methods:
To ensure that an action or bulk action is visible or hidden for a user, you can use the assertTableActionVisible() / assertTableActionHidden() or assertTableBulkActionVisible() / assertTableBulkActionHidden() methods:

Button Style

To ensure an action or bulk action has the correct label, you can use assertTableActionHasLabel() / assertTableBulkActionHasLabel() and assertTableActionDoesNotHaveLabel() / assertTableBulkActionDoesNotHaveLabel():
To ensure an action or bulk action’s button is showing the correct icon, you can use assertTableActionHasIcon() / assertTableBulkActionHasIcon() or assertTableActionDoesNotHaveIcon() / assertTableBulkActionDoesNotHaveIcon():
To ensure an action or bulk action’s button is displaying the right color, you can use assertTableActionHasColor() / assertTableBulkActionHasColor() or assertTableActionDoesNotHaveColor() / assertTableBulkActionDoesNotHaveColor():

URL

To ensure an action or bulk action has the correct URL traits, you can use assertTableActionHasUrl(), assertTableActionDoesNotHaveUrl(), assertTableActionShouldOpenUrlInNewTab(), and assertTableActionShouldNotOpenUrlInNewTab():