I get .toEqual () to check if all fields are equal for simple objects:
expect(
{"key1":"pink wool","key2":"diorite"}
).toEqual(
{"key2":"diorite","key1":"pink wool"}
);
So it goes.
But for arrays, this is not the case:
expect(["ping wool", "diorite"]).toEqual(["diorite", "pink wool"]);
There seems to be no helper function that does this in jest docs, i.e. checks the equality of two arrays regardless of their element positions. Is it necessary to check each element in one array against all elements in another and vice versa? Or is there another way?
source
share