diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 7d3e62a1..426f63b4 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -9681,7 +9681,7 @@ getJasmineRequireObj().Spy = function(j$) { "Spy '" + strategyArgs.name + "' received a call with arguments " + - j$.basicPrettyPrinter_(Array.prototype.slice.call(args)) + + matchersUtil.pp(Array.prototype.slice.call(args)) + ' but all configured strategies specify other arguments.' ); } else { diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index f5d2940f..6112e5ba 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -3855,6 +3855,35 @@ describe('Env integration', function() { expect(failedExpectations).toEqual([]); }); + it('uses custom object formatters in spy strategy argument mismatch errors', async function() { + env.it('a spec', function() { + env.addCustomObjectFormatter(function(value) { + if (typeof value === 'string') { + return 'custom:' + value; + } + }); + const spy = env + .createSpy('foo') + .withArgs('x') + .and.returnValue(''); + spy('y'); + }); + + let failedExpectations; + env.addReporter({ + specDone: r => (failedExpectations = r.failedExpectations) + }); + + await env.execute(); + expect(failedExpectations).toEqual([ + jasmine.objectContaining({ + message: jasmine.stringContaining( + 'received a call with arguments [ custom:y ]' + ) + }) + ]); + }); + describe('#spyOnGlobalErrorsAsync', function() { const leftInstalledMessage = 'Global error spy was not uninstalled. ' + diff --git a/src/core/Spy.js b/src/core/Spy.js index 108cd835..41180f42 100644 --- a/src/core/Spy.js +++ b/src/core/Spy.js @@ -161,7 +161,7 @@ getJasmineRequireObj().Spy = function(j$) { "Spy '" + strategyArgs.name + "' received a call with arguments " + - j$.basicPrettyPrinter_(Array.prototype.slice.call(args)) + + matchersUtil.pp(Array.prototype.slice.call(args)) + ' but all configured strategies specify other arguments.' ); } else {