© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
23 replies
JJSanders

Question about testing my OrderForm

I have an Order Form which I would like to test. So I have an OrderResource and the url to the form is:
admin/orders/create
admin/orders/create
I believe that this corresponds to:
'create' => Pages\CreateOrder::route('/create'),
'create' => Pages\CreateOrder::route('/create'),


So I wrote a test for this like so:
livewire(CreateOrder::class)
    ->fillForm([
        'brand_id' => $brand->id,
    ])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);
livewire(CreateOrder::class)
    ->fillForm([
        'brand_id' => $brand->id,
    ])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);

But when I run this I get:

Attempt to read property "form" on null.

at vendor/filament/forms/src/Testing/TestsForms.php:125
121▕ public function assertFormExists(): Closure
122▕ {
123▕ return function (string $name = 'form'): static {
124▕ /** @var ComponentContainer $form */
➜ 125▕ $form = $this->instance()->{$name};
126▕
127▕ $livewireClass = $this->instance()::class;
128▕
129▕ Assert::assertInstanceOf(


MyCreateOrder class doesn't have a form property. I'm wondering where the $form property is set that renders the form when go to the aforementioned url

How can I solve this?

Thanks
Solution
you didn't
login()
login()

it('Can only select suppliers related to the brand', function () {
    login();

    $brand = Brand::factory()->create();
    $suppliers = Supplier::factory()
        ->count(2)
        ->hasAttached($brand)
        ->create();
    $this->get(OrderResource::getUrl('create'));
    livewire(CreateOrder::class)
        ->fillForm([
            'brand_id' => $brand->id,
        ])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);
});
it('Can only select suppliers related to the brand', function () {
    login();

    $brand = Brand::factory()->create();
    $suppliers = Supplier::factory()
        ->count(2)
        ->hasAttached($brand)
        ->create();
    $this->get(OrderResource::getUrl('create'));
    livewire(CreateOrder::class)
        ->fillForm([
            'brand_id' => $brand->id,
        ])->assertFormSet(['supplier_id' => $suppliers->pluck('id')->toArray()]);
});
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Question about unit testing in Filament
FilamentFFilament / ❓┊help
17mo ago
Channel about testing
FilamentFFilament / ❓┊help
2y ago
Question about tables
FilamentFFilament / ❓┊help
2y ago
Question about Action
FilamentFFilament / ❓┊help
3y ago