Use j$.pp instead of JSON.stringify() for pretty printing

This commit is contained in:
James Bunton
2018-02-27 10:22:06 +11:00
parent 9ee85c35d2
commit 1149d4edde
2 changed files with 2 additions and 15 deletions

View File

@@ -124,18 +124,7 @@ describe("ExceptionFormatter", function() {
var result = new jasmineUnderTest.ExceptionFormatter().stack(error);
expect(result).toMatch(/error properties: {/);
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/);
expect(result).toMatch(/error properties:.*someProperty.*hello there/);
});
});

View File

@@ -74,9 +74,7 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
}
if (!empty) {
try {
return 'error properties: ' + JSON.stringify(result, null, 2) + '\n';
} catch (_) {}
return 'error properties: ' + j$.pp(result) + '\n';
}
return '';