adnanerlansyah403's avatar

How to testing pagination in laravel livewire

hello everyone, I want to ask. How to test pagination in laravel livewire. this is my code :

   public function testViewAllMyProjecWithPaginationLivewire()
    {
        $component = Livewire::test(ShowMyProject::class);

        $component->assertStatus(200)
                ->assertSee("paginator-page");

    }

So I checked with method assertSee(), especially when I wanted to change the number of paginates in the render method. so that I don't change it directly in the livewire component. or is there another best way to do testing pagination on laravel livewire?

Thanks, everyone.

0 likes
1 reply
vincent15000's avatar

You can for example code your pagination to display only 10 items.

Then you create 16 items in your database.

And you simulate the click on the button to display page 2 and you check if you see 6 items, you can even check if you see the last 6 datas created.

1 like

Please or to participate in this conversation.