Skip to content

Commit 33e6429

Browse files
committed
Better test
1 parent e69226e commit 33e6429

File tree

1 file changed

+35
-7
lines changed
  • dev-packages/node-integration-tests/suites/anr

1 file changed

+35
-7
lines changed

dev-packages/node-integration-tests/suites/anr/test.ts

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,39 @@ const ANR_EVENT = {
5252
},
5353
};
5454

55+
const ANR_EVENT_WITHOUT_STACKTRACE = {
56+
// Ensure we have context
57+
contexts: {
58+
trace: {
59+
span_id: expect.stringMatching(/[a-f0-9]{16}/),
60+
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
61+
},
62+
device: {
63+
arch: expect.any(String),
64+
},
65+
app: {
66+
app_start_time: expect.any(String),
67+
},
68+
os: {
69+
name: expect.any(String),
70+
},
71+
culture: {
72+
timezone: expect.any(String),
73+
},
74+
},
75+
// and an exception that is our ANR
76+
exception: {
77+
values: [
78+
{
79+
type: 'ApplicationNotResponding',
80+
value: 'Application Not Responding for at least 100 ms',
81+
mechanism: { type: 'ANR' },
82+
stacktrace: {},
83+
},
84+
],
85+
},
86+
};
87+
5588
const ANR_EVENT_WITH_SCOPE = {
5689
...ANR_EVENT,
5790
user: {
@@ -98,16 +131,11 @@ conditionalTest({ min: 16 })('should report ANR when event loop blocked', () =>
98131
createRunner(__dirname, 'indefinite.mjs').withMockSentryServer().expect({ event: ANR_EVENT }).start(done);
99132
});
100133

101-
test('With --inspect', done => {
102-
const ANR_EVENT_NO_STACKTRACE = { ...ANR_EVENT };
103-
if (ANR_EVENT_NO_STACKTRACE?.exception?.values?.[0]?.stacktrace) {
104-
(ANR_EVENT_NO_STACKTRACE.exception.values[0].stacktrace as any) = {};
105-
}
106-
134+
test("With --inspect the debugger isn't used", done => {
107135
createRunner(__dirname, 'basic.mjs')
108136
.withMockSentryServer()
109137
.withFlags('--inspect')
110-
.expect({ event: ANR_EVENT_WITH_SCOPE })
138+
.expect({ event: ANR_EVENT_WITHOUT_STACKTRACE })
111139
.start(done);
112140
});
113141

0 commit comments

Comments
 (0)