Testing with Tenancy

How can I make test with tenancy? Got this error now
it('has a form', function () {
    livewire(CreateTag::class)
        ->assertFormExists();
});

Missing required parameter for [Route: filament.client.resources.tags.index] [URI: client/{tenant}/tags] [Missing parameter: tenant].
Solution
not taking credit for everyone shard on that thread, thank you all ❤️

but feels this can help other if it marks as resolved and got indexed
it also looks like a good "trick" to add 😂
so I am copy it here


test render tenant owned records
use function Pest\Livewire\livewire;
 
it('can only render tenant owned records', function () { // Edit logic here ??
    $posts = Post::factory()->count(4)->create();
    $trashedPosts = Post::factory()->trashed()->count(6)->create();
 
    livewire(PostResource\Pages\ListPosts::class)
        ->assertCanSeeTableRecords($posts)
        ->assertCanNotSeeTableRecords($trashedPosts)
        ->assertCountTableRecords(4);
});


set tenant for tests
beforeEach(function ((){
    Filament::setTenant(Mytenantmodel::factory()->create());
});
Was this page helpful?