Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

wahyuMar's avatar

Livewire unit test. Avoid livewire testing to run render method

As we know, if we need to do some lazy load on setting some property inside our component class we can simply use wire:model.prefer and livewire will not run render method when we set the field/property. But how we can do that if we want same logic on backend?

Livewire::test( ProductDescription::class, [$this->request, (int) $this->product->products_id]) ->set('productDesc', $newDescription) ->call('update');

0 likes
3 replies
tisuchi's avatar

@wahyumar How about set()->call()->assertDontSee()?

For example:


Livewire::test(ProductDescription::class, [
    $this->request, 
    (int) $this->product->products_id
])
->set('productDesc', $newDescription)
->call('update')
->assertDontSee('render');
1 like
wahyuMar's avatar

@tisuchi assertDontSee is a method to test that the rendered html doesnt contains the string. What i want is everytime i set someProperty using set() method, the livewire only change the value of property without re-run the render() method.

wahyuMar's avatar

Currently i just remove the script that caused error when the livewire re-rendering. Its working fine but still not really what i want. The rerun for render() method still executed in the unit test.

Please or to participate in this conversation.