I have seen different implementations of solutions to this problem, however none seem to work for me.
Say I have an array of objects (length of 6) containing unique data with structure:
{
first_name,
last_name,
age,
dob,
address_1,
postal_code
}
How would I compare if this array contains partial elements of another object array whose objects have slightly shorter structure:
{
first_name,
last_name,
age
}
I understand that if I were comparing singular items I could use something like:
expect(response[i]).toMatchObject(expected[i]);
however I am unsure on how I would compare full arrays...
I have seen something like this:
expect(state).toEqual(
expect.arrayContaining([
expect.objectContaining({
type: 'END'
})
])
)
But I cannot get it to work.
Aucun commentaire:
Enregistrer un commentaire