I’m trying to test a sort by call for a table, The sort by works in practice but I cannot generate a failing test, my test always passes so I’m not testing it correctly.
Steps to Reproduce:
This is the test:
Livewire::test(Roles::class)
        ->call('sortBy', 'blah')
        ->assertSet('sortField', 'blah')
        ->call('roles')
        ->assertStatus(200);
the param blah should match a database column, I don’t have a column called blah so should fail, but it passes.
the component:
class Roles extends Component
{
    use WithPagination;
    public $paginate;
    public $query;
    public $sortField = 'name';
    public $sortAsc = true;
    protected $queryString = ['query'];
    public function render()
    {
        abort_if_cannot('view_roles');
        return view('livewire.roles.roles');
    }
    public function builder()
    {
        return Role::orderBy($this->sortField, $this->sortAsc ? 'asc' : 'desc');
    }
    public function sortBy($field)
    {
        if ($this->sortField === $field) {
            $this->sortAsc = ! $this->sortAsc;
        } else {
            $this->sortAsc = true;
        }
        $this->sortField = $field;
    }
    public function roles()
    {
        $query = $this->builder();
        if ($this->query) {
            $query->where('name', 'like', '%'.$this->query.'%');
        }
        return $query->paginate($this->paginate);
    }
    public function deleteRole($id): void
    {
        abort_if_cannot('delete_roles');
        $this->builder()->findOrFail($id)->delete();
        $this->dispatchBrowserEvent('close-modal');
    }
}
Are you using the latest version of Livewire: v2.3.6
If I attempt to run:
wire:click.prevent="sortBy('blah')
Then I do get an SQL error as expected.
Anyone know how I can update my test to actually see there’s an error.