Testing Production Filament Applications: From One Panel to Multi-Tenancy

Testing Production Filament Applications: From One Panel to Multi-Tenancy

A single-panel Filament app is almost trivial to test. Add a second panel, then tenancy, then a client's coverage requirements, and the testing setup becomes architecture in its own right. Here's how that growth actually looks, stage by stage.

I thought testing would mostly be about writing assertions.

It wasn't. The hardest part turned out to be making the test environment behave like the application behaves in production.

A single-panel Filament app is almost trivial to test. Add a second panel, then tenancy, then different coverage requirements, and the testing setup becomes architecture in its own right. Here's how that growth actually looks, one stage at a time.

1. A single panel is easy

A simple, single-panel project needs almost nothing in Pest.php:

pest()->extend(TestCase::class)
    ->use(RefreshDatabase::class)
    ->beforeEach(fn () => $this->seed(DatabaseSeeder::class))
    ->in('Feature');

pest()->extend(TestCase::class)
    ->use(RefreshDatabase::class)
    ->in('Unit');

One TestCase, one seeder, done. This is also as far as most tutorials go, because it's the version of the problem that doesn't need a real architecture behind it yet.

2. Two panels change everything