Skip to content

Testing Sections

Use SectionDataFactory to build a fully-resolved SectionData fixture in your Pest tests:

php
use FilamentCraft\Testing\SectionDataFactory;

it('renders the heading', function (): void {
    $section = SectionDataFactory::for(MyHeroSection::class)
        ->settings(['heading' => 'Hello'])
        ->blocks([['id' => 'p1', 'type' => 'proof', 'settings' => ['value' => '3x']]])
        ->make();

    expect($section->settings->get('heading'))->toBe('Hello');
});

The factory exercises the same SectionData::fromArray() pipeline the editor uses, so transformer-resolved values (ImageValue, LinkValue, ColorSchemeValue) are produced exactly as in production.

Proprietary — distributed via Anystack.