Use j$.pp instead of JSON.stringify() for pretty printing
This commit is contained in:
@@ -124,18 +124,7 @@ describe("ExceptionFormatter", function() {
|
|||||||
|
|
||||||
var result = new jasmineUnderTest.ExceptionFormatter().stack(error);
|
var result = new jasmineUnderTest.ExceptionFormatter().stack(error);
|
||||||
|
|
||||||
expect(result).toMatch(/error properties: {/);
|
expect(result).toMatch(/error properties:.*someProperty.*hello there/);
|
||||||
expect(result).toMatch(/"someProperty": "hello there"/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("drops error properties if there is a cycle", function() {
|
|
||||||
var error;
|
|
||||||
try { throw new Error("an error") } catch(e) { error = e; }
|
|
||||||
error.someProperty = error;
|
|
||||||
|
|
||||||
var result = new jasmineUnderTest.ExceptionFormatter().stack(error);
|
|
||||||
|
|
||||||
expect(result).not.toMatch(/error properties/);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -74,9 +74,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
try {
|
return 'error properties: ' + j$.pp(result) + '\n';
|
||||||
return 'error properties: ' + JSON.stringify(result, null, 2) + '\n';
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
|||||||
Reference in New Issue
Block a user