F
Filament14mo ago
Hemith

Testing create form modal on ManageResource page.

it('can create author', function () {
livewire(ManageAuthors::class)
->callAction(CreateAction::class)
->fillForm([
'name' => 'New Author',
'email' => '[email protected]'
])
->call('create');

dd(Author::all());
});
it('can create author', function () {
livewire(ManageAuthors::class)
->callAction(CreateAction::class)
->fillForm([
'name' => 'New Author',
'email' => '[email protected]'
])
->call('create');

dd(Author::all());
});
Here is my code for testing the form. But nothing seems to be outputting.
2 Replies
Hemith
HemithOP14mo ago
I managed to do it like this
it('can create author', function () {
expect(Author::count())->toBe(0);

livewire(ManageAuthors::class)
->callAction(CreateAction::class, [
'name' => 'New Name',
'email' => '[email protected]'
])
->assertHasNoActionErrors();

$createdAuthor = Author::first();

expect($createdAuthor->name)->toBe('New Name');
expect($createdAuthor->email)->toBe('[email protected]');
expect(Author::count())->toBe(1);
});
it('can create author', function () {
expect(Author::count())->toBe(0);

livewire(ManageAuthors::class)
->callAction(CreateAction::class, [
'name' => 'New Name',
'email' => '[email protected]'
])
->assertHasNoActionErrors();

$createdAuthor = Author::first();

expect($createdAuthor->name)->toBe('New Name');
expect($createdAuthor->email)->toBe('[email protected]');
expect(Author::count())->toBe(1);
});
bwurtz999
bwurtz9995mo ago
I'm trying to follow along with your example
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
'menu' => UploadedFile::fake(),
])
->assertHasNoActionErrors();
livewire(ManageBeverageCarts::class)
->callAction(CreateAction::class, data: [
'team_id' => $team->id,
'name' => $name,
'menu' => UploadedFile::fake(),
])
->assertHasNoActionErrors();
but I keep getting the error Property type not supported in Livewire for property: [{}]. I've tried searching on Google and in this Discord but I can't find anything to explain this. Do you have any ideas?
Want results from more Discord servers?
Add your server