Skip to content

Commit 288f8f9

Browse files
committed
.
1 parent facdc00 commit 288f8f9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/helpers/__tests__/errors.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('ErrorWithStack', () => {
2929
});
3030
});
3131

32-
describe('copyStackTrace', () => {
32+
describe('copyStackTraceIfNeeded', () => {
3333
test('should copy stack trace from source to target when both are Error instances', () => {
3434
const target = new Error('Target error');
3535
const source = new Error('Source error');
@@ -60,8 +60,14 @@ describe('copyStackTrace', () => {
6060

6161
const target = new Error('Target error');
6262
const originalStack = target.stack;
63-
const sourceNotError = { message: 'Not an error' };
6463

64+
copyStackTraceIfNeeded(target, undefined);
65+
expect(target.stack).toBe(originalStack);
66+
67+
copyStackTraceIfNeeded(target, null as unknown as Error);
68+
expect(target.stack).toBe(originalStack);
69+
70+
const sourceNotError = { message: 'Not an error' };
6571
copyStackTraceIfNeeded(target, sourceNotError as Error);
6672
expect(target.stack).toBe(originalStack);
6773

0 commit comments

Comments
 (0)