Make toEqual matcher report the difference between objects

- Mismatches deep within object/array structures are pinpointed with a JsonPath-like syntax.
This commit is contained in:
Ben Christel
2016-07-18 15:17:00 -07:00
committed by Ben Christel
parent 5a76e59d5b
commit d5e6bf47ed
17 changed files with 2251 additions and 1156 deletions

View File

@@ -67,5 +67,21 @@ getJasmineRequireObj().util = function() {
return descriptor;
};
util.objectDifference = function(obj, toRemove) {
var diff = {};
for (var key in obj) {
if (util.has(obj, key) && !util.has(toRemove, key)) {
diff[key] = obj[key];
}
}
return diff;
};
util.has = function(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
};
return util;
};