From 1149d4edde73abd7aaf396c2bccd037ea9dea160 Mon Sep 17 00:00:00 2001 From: James Bunton Date: Tue, 27 Feb 2018 10:22:06 +1100 Subject: [PATCH] Use j$.pp instead of JSON.stringify() for pretty printing --- spec/core/ExceptionFormatterSpec.js | 13 +------------ src/core/ExceptionFormatter.js | 4 +--- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/spec/core/ExceptionFormatterSpec.js b/spec/core/ExceptionFormatterSpec.js index 0e4f074c..e896a5fe 100644 --- a/spec/core/ExceptionFormatterSpec.js +++ b/spec/core/ExceptionFormatterSpec.js @@ -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/); }); }); diff --git a/src/core/ExceptionFormatter.js b/src/core/ExceptionFormatter.js index 71961776..aa3a62ae 100644 --- a/src/core/ExceptionFormatter.js +++ b/src/core/ExceptionFormatter.js @@ -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 '';