Level 1
By the way, this assertion works as expected:
->assertSet('showEditForm', true);
But I think assertSee is more reliable, if it works as expected.
Ia have a modal create form:
<div id="edit-form" x-data x-cloak
x-show="$wire.showEditForm">Some Content</div>
It is hidden by default:
public bool $showEditForm = false;
Visibility is toggled with action on button:
<button type="button" wire:click="create" wire:loading.attr="disabled">Open modal</button>
Create and showEditForm methods:
public function create(): void
{
$this->showEditForm();
}
private function showEditForm(): void
{
$this->showEditForm = true;
}
All works fine, but my test passes, even without calling create to open modal and render it:
public function test_add_new_form_modal_can_be_rendered()
{
Livewire::test(MyForms::class)
// ->call('create')
->assertSee(__('Save'));
}
Here I'm testind, that the Save button in my modal form is rendered. If I remove form from the template totally, test fails. Why does the test passes?
Please or to participate in this conversation.