-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(replay): Ensure circular references are handled (#7752)
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/replay/test/unit/coreHandlers/util/addBreadcrumbEvent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { BASE_TIMESTAMP } from '../../..'; | ||
import { addBreadcrumbEvent } from '../../../../src/coreHandlers/util/addBreadcrumbEvent'; | ||
import type { EventBufferArray } from '../../../../src/eventBuffer/EventBufferArray'; | ||
import { setupReplayContainer } from '../../../utils/setupReplayContainer'; | ||
|
||
jest.useFakeTimers(); | ||
|
||
describe('Unit | coreHandlers | util | addBreadcrumbEvent', function () { | ||
beforeEach(function () { | ||
jest.setSystemTime(BASE_TIMESTAMP); | ||
}); | ||
|
||
it('handles circular references', async () => { | ||
const breadcrumb: any = { | ||
category: 'console', | ||
message: 'Test message', | ||
thisIsNull: null, | ||
thisIsUndefined: undefined, | ||
timestamp: BASE_TIMESTAMP / 1000, | ||
}; | ||
breadcrumb['circular'] = breadcrumb; | ||
|
||
const replay = setupReplayContainer(); | ||
addBreadcrumbEvent(replay, breadcrumb); | ||
|
||
await undefined; | ||
await undefined; | ||
await undefined; | ||
await undefined; | ||
await undefined; | ||
|
||
expect((replay.eventBuffer as EventBufferArray).events).toEqual([ | ||
{ | ||
type: 5, | ||
timestamp: BASE_TIMESTAMP, | ||
data: { | ||
tag: 'breadcrumb', | ||
payload: { | ||
category: 'console', | ||
message: 'Test message', | ||
thisIsNull: null, | ||
thisIsUndefined: '[undefined]', | ||
circular: '[Circular ~]', | ||
timestamp: BASE_TIMESTAMP / 1000, | ||
}, | ||
}, | ||
}, | ||
]); | ||
}); | ||
}); |