Skip to content

Commit 43ce230

Browse files
committed
add test for undefined handling
1 parent 5543bd0 commit 43ce230

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

packages/core/test/lib/utils/applyScopeDataToEvent.test.ts

+48
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,54 @@ describe('mergeScopeData', () => {
194194
});
195195

196196
describe('applyScopeDataToEvent', () => {
197+
it('should correctly merge nested event and scope data with undefined values', () => {
198+
const eventData: Event = {
199+
user: {
200+
name: 'John',
201+
age: undefined,
202+
location: 'New York',
203+
newThing: undefined,
204+
},
205+
extra: {},
206+
};
207+
208+
const scopeData: ScopeData = {
209+
eventProcessors: [],
210+
breadcrumbs: [],
211+
user: {
212+
name: 'John',
213+
age: 30,
214+
location: 'Vienna',
215+
role: 'developer',
216+
thing: undefined,
217+
},
218+
tags: {},
219+
extra: {},
220+
contexts: {},
221+
attachments: [],
222+
propagationContext: { traceId: '1', sampleRand: 0.42 },
223+
sdkProcessingMetadata: {},
224+
fingerprint: [],
225+
};
226+
227+
applyScopeDataToEvent(eventData, scopeData);
228+
229+
// Verify merged data structure
230+
expect(eventData).toEqual({
231+
user: {
232+
name: 'John',
233+
age: undefined,
234+
location: 'New York',
235+
role: 'developer',
236+
thing: undefined,
237+
newThing: undefined,
238+
},
239+
extra: {},
240+
breadcrumbs: undefined,
241+
sdkProcessingMetadata: {},
242+
});
243+
});
244+
197245
it("doesn't apply scope.transactionName to transaction events", () => {
198246
const data: ScopeData = {
199247
eventProcessors: [],

0 commit comments

Comments
 (0)