Asserting deep equality

To assert that the res object has not been modified, we need to perform a deep comparison of the res object before and after checkEmptyPayload has been called.

Instead of implementing this function ourselves, we can save time by using existing utility libraries. For instance, Lodash provides the cloneDeep method (lodash.com/docs/#cloneDeepfor deep cloning, and the isEqual method (lodash.com/docs/#isEqualfor deep object comparison.

To use these methods in our code, we can install the lodash package from npm, which contains hundreds of utility methods. However, we won't be using most of these methods in our project; if we install the entire utility library, most of the code would be unused. We should always try to ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.