vendredi 2 avril 2021

What does "serializing to the same structure" mean in Jest?

When testing with Jest, one of my expect(A).toMatchObject(B) statements failed with this error:

Compared values serialize to the same structure. Printing internal object structure without calling 'toJSON' instead.

I'm curious about some terminology used here; what does it mean for two values to "serialize to the same structure"? I understand that serialization is the act of putting things (data) into a series, and I'd guess that "structure" refers to the data of an object, but what is meant by "serialize to the same structure"?

Also, why would two values serializing to the same structure imply that the internal object structures should be printed, I quote, "without calling toJSON instead?" What would this process of "calling toJSON instead" even entail, exactly?

(Keep in mind that I read the Jest docs already, and couldn't find what I'm asking about.)

Aucun commentaire:

Enregistrer un commentaire