What seems to be the problem:
I’ve upgraded to the latest Livewire (v1 to v2). The site works as expected in the browser and all looks good. However, my tests are failing for a reason they should not be. Very basic assertions of default component values are failing with
Failed asserting that null is true.
Steps to Reproduce:
I have a simple Livewire Component that has a public property $type that is set to ‘info’ as a default.
If I run the following basic test, I get the above error:
Livewire::test('users.send-notification-all') ->assertSet('type', 'info');
However, if I change the test as follows:
$comp = Livewire::test('users.send-notification-all'); $this->assertTrue($comp->type === 'info');
$comp = Livewire::test('users.send-notification-all'); $this->assertEquals('info', $comp->get('type'));
The test passes.
Also if I change as per upgrade guide:
Livewire::test('users.send-notification-all') ->assertPayloadSet('type', 'info');
I still get the failure.
When it fails I don’t get any errors in my logs and as mentioned above the component works as expected in the browser. Any idea where to start in debugging this? I’m running Laravel v8.8.0, PHP 7.3.11.
Are you using the latest version of Livewire: Yes
Do you have any screenshots or code examples: