Skip to content

Commit 90afdd3

Browse files
authored
fix(test): filter for app start transaction in ErrorsScreen test (#5251)
1 parent 3bd3f0d commit 90afdd3

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

samples/react-native/e2e/captureErrorsScreenTransaction.test.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,34 @@ describe('Capture Errors Screen Transaction', () => {
3131
});
3232

3333
it('envelope contains transaction context', async () => {
34-
const item = getItemOfTypeFrom<EventItem>(
35-
getErrorsEnvelope(),
36-
'transaction',
37-
);
34+
const envelope = getErrorsEnvelope();
35+
36+
const items = envelope[1];
37+
const transactions = items.filter(([header]) => header.type === 'transaction');
38+
const appStartTransaction = transactions.find(([_header, payload]) => {
39+
const event = payload as any;
40+
return event.transaction === 'ErrorsScreen' &&
41+
event.contexts?.trace?.origin === 'auto.app.start';
42+
});
43+
44+
expect(appStartTransaction).toBeDefined();
45+
46+
const [header, payload] = appStartTransaction!;
3847

39-
expect(item).toEqual([
48+
expect(header).toEqual(
4049
expect.objectContaining({
4150
length: expect.any(Number),
4251
type: 'transaction',
43-
}),
52+
})
53+
);
54+
55+
expect(payload).toEqual(
4456
expect.objectContaining({
4557
platform: 'javascript',
4658
transaction: 'ErrorsScreen',
4759
contexts: expect.objectContaining({
48-
trace: {
49-
data: {
60+
trace: expect.objectContaining({
61+
data: expect.objectContaining({
5062
'route.has_been_seen': false,
5163
'route.key': expect.stringMatching(/^ErrorsScreen/),
5264
'route.name': 'ErrorsScreen',
@@ -56,15 +68,15 @@ describe('Capture Errors Screen Transaction', () => {
5668
'sentry.sample_rate': 1,
5769
'sentry.source': 'component',
5870
'thread.name': 'javascript',
59-
},
71+
}),
6072
op: 'ui.load',
6173
origin: 'auto.app.start',
6274
span_id: expect.any(String),
6375
trace_id: expect.any(String),
64-
},
76+
}),
6577
}),
66-
}),
67-
]);
78+
})
79+
);
6880
});
6981

7082
it('contains app start measurements', async () => {

0 commit comments

Comments
 (0)