Skip to content

Commit c4a718c

Browse files
committed
Fix flakey worker thread test
1 parent 3f83db2 commit c4a718c

File tree

1 file changed

+34
-29
lines changed
  • dev-packages/node-integration-tests/suites/thread-blocked-native

1 file changed

+34
-29
lines changed

dev-packages/node-integration-tests/suites/thread-blocked-native/test.ts

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -156,39 +156,44 @@ describe('Thread Blocked Native', { timeout: 30_000 }, () => {
156156
});
157157

158158
test('worker thread', async () => {
159-
const ANR_EVENT_THREADS: Event = {
160-
...ANR_EVENT,
161-
exception: {
162-
...EXCEPTION('2'),
163-
},
164-
threads: {
165-
values: [
166-
{
167-
id: '0',
168-
name: 'main',
169-
crashed: false,
170-
current: true,
171-
main: true,
172-
stacktrace: {
173-
frames: expect.any(Array),
174-
},
175-
},
176-
{
177-
id: '2',
178-
name: 'worker-2',
179-
crashed: true,
180-
current: true,
181-
main: false,
182-
},
183-
],
184-
},
185-
};
186-
187159
const instrument = join(__dirname, 'instrument.mjs');
188160
await createRunner(__dirname, 'worker-main.mjs')
189161
.withMockSentryServer()
190162
.withFlags('--import', instrument)
191-
.expect({ event: ANR_EVENT_THREADS })
163+
.expect({
164+
event: event => {
165+
const crashedThread = event.threads?.values?.find(thread => thread.crashed)?.id as string;
166+
expect(crashedThread).toBeDefined();
167+
168+
expect(event).toMatchObject({
169+
...ANR_EVENT,
170+
exception: {
171+
...EXCEPTION(crashedThread),
172+
},
173+
threads: {
174+
values: [
175+
{
176+
id: '0',
177+
name: 'main',
178+
crashed: false,
179+
current: true,
180+
main: true,
181+
stacktrace: {
182+
frames: expect.any(Array),
183+
},
184+
},
185+
{
186+
id: crashedThread,
187+
name: `worker-${crashedThread}`,
188+
crashed: true,
189+
current: true,
190+
main: false,
191+
},
192+
],
193+
},
194+
});
195+
},
196+
})
192197
.start()
193198
.completed();
194199
});

0 commit comments

Comments
 (0)