I’m having issues when using expect.objectContaining()
because the result diff is unreadable and I always tried to use toMatchObject()
to avoid that issue.
Here is a test example
expect(repository.save).toHaveBeenCalledWith(expect.objectContaining({
cpf: customer.cpf,
name: customer.name,
email: customer.email,
surname: customer.surname,
birthday: customer.birthday,
address: {
a: 1
},
}))
expect(repository.save.mock.calls[0][0]).toMatchObject({
cpf: customer.cpf,
name: customer.name,
email: customer.email,
surname: customer.surname,
birthday: customer.birthday,
address: {
a: 1
},
})
The expect.objectContaining()
returns this unreadable result
In exchange, the toMatchObject()
returns this
Is there a way to improve it?