Skip to content

Commit 5349014

Browse files
Add another test case
1 parent 07fe7d4 commit 5349014

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/utils.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,25 @@ describe('serializeError', () => {
246246
});
247247
});
248248

249+
it('handles class that has serialize function', () => {
250+
class MockClass {
251+
serialize() {
252+
return { code: 1, message: 'foo' };
253+
}
254+
}
255+
const error = new MockClass();
256+
const result = serializeError(error);
257+
expect(result).toStrictEqual({
258+
code: 1,
259+
message: 'foo',
260+
});
261+
262+
expect(JSON.parse(JSON.stringify(result))).toStrictEqual({
263+
code: 1,
264+
message: 'foo',
265+
});
266+
});
267+
249268
it('removes non JSON-serializable props on cause', () => {
250269
const error = new Error('foo');
251270
// @ts-expect-error Intentionally using wrong type

0 commit comments

Comments
 (0)