This should indeed work. What versions of Laravel and Livewire are you using?
Feb 4, 2024
5
Level 63
BadMethodCallException: Method Illuminate\Http\Response::assertSeeLivewire does not exist.
Hello,
With Livewire 3.4.
When I run this test.
<?php
namespace Tests\Feature\Livewire\Pages;
use App\Livewire\Pages\CategoriesPage;
use App\Models\Category;
use App\Models\User;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Livewire\Livewire;
use Tests\TestCase;
class CategoriesTest extends TestCase
{
use RefreshDatabase;
public $user;
public $admin;
public function setUp(): void
{
parent::setUp();
$this->user = User::factory()->create();
$this->admin = User::factory()->admin()->create();
}
/** @test */
public function categories_page_component_loads(): void
{
Livewire::
test(CategoriesPage::class)
->assertStatus(200);
}
/** @test */
public function admin_can_see_the_categories_page_component(): void
{
$this
->actingAs($this->admin)
->get('admin/categories')
->assertSeeLivewire(CategoriesPage::class);
}
}
I get this error.
BadMethodCallException: Method Illuminate\Http\Response::assertSeeLivewire does not exist.
According to the documentation, it should work.
https://livewire.laravel.com/docs/testing#testing-a-page-contains-a-component
Is it a bug ? Perhaps I'm doing something wrong ?
Thanks for your help.
V
Please or to participate in this conversation.