Show us the Livewire component.
May 23, 2025
2
Level 6
Very odd testing error
I am posting this under filament since that's where I'm testing but I think this might be an issue with laravel. Has anyone seen this before?
Here is my test:
it('can edit a user profile', function () {
$userProfile = UserProfile::factory()
->create([
'tenant_id' => $this->tenant->id,
]);
Livewire::test(EditUserProfile::class, [
'record' => $userProfile->id,
])
->fillForm([
'first_name' => 'Updated',
'last_name' => 'Name',
'email' => '[email protected]',
'phone' => '0987654321',
])
->call('save')
->assertHasNoFormErrors();
$this->assertDatabaseHas('user_profiles', [
'id' => $userProfile->id,
'first_name' => 'Updated',
'last_name' => 'Name',
'email' => '[email protected]',
'phone' => '0987654321',
]);
});
and the error I get:
Failed asserting that a row in the table [user_profiles] matches the attributes {
"id": 2,
"first_name": "Updated",
"last_name": "Name",
"email": "[email protected]",
"phone": "0987654321"
}.
Found similar results: [
{
"id": 2,
"first_name": "Updated",
"last_name": "Name",
"\"email\"": "email", // <---- Issue is here. WTF???
"phone": "0987654321"
}
].
As you can see the result from the assertDatabaseHas is adding extra escape strings to the email key. This makes no sense to me. Anyone have any idea where these escaped strings are coming from?
I have same exact issue on the create profile test as well.
Please or to participate in this conversation.