3 declare namespace Cypress {
5 deepCompare: typeof deepCompare,
9 function deepCompare(actual : any, expected : any) {
10 if(actual !== null && expected !== null){
11 let diff : any[] = [];
12 Cypress._.mergeWith(actual, expected, function (objectValue, sourceValue, key, object, source) {
13 if ( !(_.isEqual(objectValue, sourceValue)) && (Object(objectValue) !== objectValue)) {
14 diff.push("key: " +key + ", expected: " + sourceValue + ", actual: " + objectValue);
18 Cypress._.mergeWith(expected, actual, function (objectValue, sourceValue, key, object, source) {
19 if ( !(_.isEqual(objectValue, sourceValue)) && (Object(objectValue) !== objectValue)) {
20 diff.push("key: " +key + ", expected: " + sourceValue + ", actual: " + objectValue);
25 console.error("diff", diff);
26 cy.log("The object are not equals", diff);
27 expect(actual).equals(expected, `diff: ${diff}, actual:${JSON.stringify(actual)}, expected:${JSON.stringify(expected)}`);
32 Cypress.Commands.add('deepCompare', deepCompare);