filament/filament
v3.2.115
v11.26.0
v3.5.6
8.3.12
A very simple test with no assertions is failing. The failure message refers to an assertion which comes from the Filament package itself, not from my test.
Consider this simple test:
<?php
use App\Livewire\Button;
use function \Pest\Livewire\livewire;
it('works properly', function () {
livewire(Button::class)
->mountAction('first');
});
And running php artisan test
gives this failure:
FAILED Tests\Feature\ButtonTest > it works properly
Failed asserting that two arrays are equal.
Array (
- 0 => 'first'
+ 0 => 'second'
)
at vendor/livewire/livewire/src/Features/SupportTesting/MakesAssertions.php:110
106β
107β if (! is_string($value) && is_callable($value)) {
108β PHPUnit::assertTrue($value($actual));
109β } else {
β 110β $strict ? PHPUnit::assertSame($value, $actual) : PHPUnit::assertEquals($value, $actual);
111β }
112β
113β return $this;
114β }
+4 vendor frames
5 tests/Feature/ButtonTest.php:9
Tests: 1 failed (1 assertions)
Duration: 0.23s
This is unexpected because I didn't make any assertions. Usually a basic test like this would just be reported as "risky" due to no assetions.
Obviously my intended test is much longer, but the problem is I cannot make any assertions of my own because the test is failing so early as described.
I expected the test above to pass but be flagged as "risky" because there are no assertions.
I also expected to be able to write a test something like this:
it('works properly', function () {
livewire(Button::class)
->mountAction('first')
->callMountedAction()
->assertActionMounted('second')
});
In other words, I expected to be able to assert that the Filament replaceMountedAction()
method is replacing the mounted action as intended.
Set up
[email protected]
/ password
app/Livewire/Button.php
and tests/Feature/ButtonTest.php
tail -f storage/logs/laravel.log
Successful execution within the Filament application itself:
first
, specifically wire:click="mountAction('first')"
secondAction()
method of Button.php
and not from the firstAction()
first action
second action
Unsuccessful execution when testing:
php artisan test
first action
https://github.com/joseph-d/filamentIssue20241007
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too