Use custom object formatters in spy strategy mismatch errors
This commit is contained in:
@@ -9681,7 +9681,7 @@ getJasmineRequireObj().Spy = function(j$) {
|
|||||||
"Spy '" +
|
"Spy '" +
|
||||||
strategyArgs.name +
|
strategyArgs.name +
|
||||||
"' received a call with arguments " +
|
"' 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.'
|
' but all configured strategies specify other arguments.'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3855,6 +3855,35 @@ describe('Env integration', function() {
|
|||||||
expect(failedExpectations).toEqual([]);
|
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() {
|
describe('#spyOnGlobalErrorsAsync', function() {
|
||||||
const leftInstalledMessage =
|
const leftInstalledMessage =
|
||||||
'Global error spy was not uninstalled. ' +
|
'Global error spy was not uninstalled. ' +
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ getJasmineRequireObj().Spy = function(j$) {
|
|||||||
"Spy '" +
|
"Spy '" +
|
||||||
strategyArgs.name +
|
strategyArgs.name +
|
||||||
"' received a call with arguments " +
|
"' 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.'
|
' but all configured strategies specify other arguments.'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user