@@ -177,43 +177,50 @@ describe('Thread Blocked Native', { timeout: 30_000 }, () => {
177177 . completed ( ) ;
178178 } ) ;
179179
180- test ( 'worker thread' , async ( ) => {
180+ test ( 'worker thread' , { timeout : 60_000 } , async ( ) => {
181181 const instrument = join ( __dirname , 'instrument.mjs' ) ;
182182 await createRunner ( __dirname , 'worker-main.mjs' )
183183 . withMockSentryServer ( )
184184 . withFlags ( '--import' , instrument )
185185 . expect ( {
186186 event : event => {
187- const crashedThread = event . threads ?. values ?. find ( thread => thread . crashed ) ?. id as string ;
187+ const crashedThread = event . threads ?. values ?. find ( thread => thread . crashed ) ?. id as string | undefined ;
188188 expect ( crashedThread ) . toBeDefined ( ) ;
189189
190+ const expectedEvent = ANR_EVENT ( ) ;
190191 expect ( event ) . toMatchObject ( {
191- ...ANR_EVENT ( ) ,
192+ ...expectedEvent ,
193+ // We compare this separately below
194+ threads : expect . any ( Object ) ,
192195 exception : {
193196 ...EXCEPTION ( crashedThread ) ,
194197 } ,
195- threads : {
196- values : [
197- {
198- id : '0' ,
199- name : 'main' ,
200- crashed : false ,
201- current : true ,
202- main : true ,
203- stacktrace : {
204- frames : expect . any ( Array ) ,
205- } ,
206- } ,
207- {
208- id : crashedThread ,
209- name : `worker-${ crashedThread } ` ,
210- crashed : true ,
211- current : true ,
212- main : false ,
213- } ,
214- ] ,
215- } ,
216198 } ) ;
199+
200+ const threadValues = event . threads ?. values ?? [ ] ;
201+ expect ( threadValues ) . toHaveLength ( 2 ) ;
202+ // Any order is fine, we just check that both are present
203+ expect ( threadValues ) . toContainEqual (
204+ expect . objectContaining ( {
205+ id : '0' ,
206+ name : 'main' ,
207+ crashed : false ,
208+ current : true ,
209+ main : true ,
210+ stacktrace : {
211+ frames : expect . any ( Array ) ,
212+ } ,
213+ } ) ,
214+ ) ;
215+ expect ( threadValues ) . toContainEqual (
216+ expect . objectContaining ( {
217+ id : crashedThread ,
218+ name : `worker-${ crashedThread } ` ,
219+ crashed : true ,
220+ current : true ,
221+ main : false ,
222+ } ) ,
223+ ) ;
217224 } ,
218225 } )
219226 . start ( )
0 commit comments