The return value of jest test interface is the same as expected.

now there is a requirement that if the return value of the interface is very complex, including an array of objects, and there are a lot of properties in the object, how can you use jest to ensure that the returned properties are the same as expected?
look at the document is full of mock some simple return values, what about complex ones? I can"t check it by hand, can I?
or is this test beyond the scope of jest?

Nov.15,2021

you can use .toEqual


upstairs has been answered, toEqual recursively checks each field of the object or array.


if you want to be exactly the same, as you said upstairs, use toEqual
if you just want to verify certain attributes, you can write judgment logic in expect , return true or false , and then toBe

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2b3c4-2ba61.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2b3c4-2ba61.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?