Show argument diffs in toHaveBeenCalledWith failure messages

* Fixes #1641
This commit is contained in:
Steve Gravrock
2019-09-03 17:12:35 -07:00
parent 19292e4ea4
commit 35d15085e3
3 changed files with 36 additions and 6 deletions

View File

@@ -45,10 +45,18 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
return ' ' + j$.pp(argsForCall);
});
var diffs = actual.calls.allArgs().map(function(argsForCall, callIx) {
var diffBuilder = new j$.DiffBuilder();
util.equals(argsForCall, expectedArgs, customEqualityTesters, diffBuilder);
return 'Call ' + callIx + ':\n' +
diffBuilder.getMessage().replace(/^/mg, ' ');
});
return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' +
' ' + j$.pp(expectedArgs) + '\n' + '' +
'but actual calls were:\n' +
prettyPrintedCalls.join(',\n') + '.';
prettyPrintedCalls.join(',\n') + '.\n\n' +
diffs.join('\n');
};
}