Skip to content

Commit 111ddb7

Browse files
committed
test: add test for custom toJSON methods attached to errors
1 parent 5b03656 commit 111ddb7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/LogMessage.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ describe('Statics', () => {
104104
expect(result).toHaveProperty('stack', err.stack);
105105
expect(result).toHaveProperty('test', true);
106106
});
107+
108+
test('should skip custom toJSON fn if error already has one', () => {
109+
const e = new Error('test');
110+
const noop = () => { /* noop */ };
111+
Object.defineProperty(e, 'toJSON', {
112+
value: noop
113+
});
114+
115+
const error = LogMessage.stubError(e);
116+
expect(error.toJSON.toString()).toBe(noop.toString());
117+
});
107118
});
108119
});
109120
});

0 commit comments

Comments
 (0)