Include property getter values in pretty-printed objects

We already call getters when comparing objects for equality and generating
diffs, so it should be safe to do it here too.

See #1966.
This commit is contained in:
Steve Gravrock
2022-05-12 17:14:13 -07:00
parent 68eaa64c31
commit bb4d18f959
3 changed files with 19 additions and 53 deletions
+3 -3
View File
@@ -323,16 +323,16 @@ describe('PrettyPrinter', function() {
);
});
it('should indicate getters on objects as such', function() {
it('should use the return value of getters', function() {
const pp = jasmineUnderTest.makePrettyPrinter();
const sampleValue = {
id: 1,
get calculatedValue() {
throw new Error("don't call me!");
return 'the getter return value';
}
};
expect(pp(sampleValue)).toEqual(
'Object({ id: 1, calculatedValue: <getter> })'
"Object({ id: 1, calculatedValue: 'the getter return value' })"
);
});