@@ -15,8 +15,10 @@ conditionalTest({ min: 12 })('async_hooks', () => {
1515 } ) ;
1616
1717 test ( 'without strategy hubs should be equal' , ( ) => {
18- runWithAsyncContext ( hub1 => {
19- runWithAsyncContext ( hub2 => {
18+ runWithAsyncContext ( ( ) => {
19+ const hub1 = getCurrentHub ( ) ;
20+ runWithAsyncContext ( ( ) => {
21+ const hub2 = getCurrentHub ( ) ;
2022 expect ( hub1 ) . toBe ( hub2 ) ;
2123 } ) ;
2224 } ) ;
@@ -28,13 +30,15 @@ conditionalTest({ min: 12 })('async_hooks', () => {
2830 const globalHub = getCurrentHub ( ) ;
2931 globalHub . setExtra ( 'a' , 'b' ) ;
3032
31- runWithAsyncContext ( hub1 => {
33+ runWithAsyncContext ( ( ) => {
34+ const hub1 = getCurrentHub ( ) ;
3235 expect ( hub1 ) . toEqual ( globalHub ) ;
3336
3437 hub1 . setExtra ( 'c' , 'd' ) ;
3538 expect ( hub1 ) . not . toEqual ( globalHub ) ;
3639
37- runWithAsyncContext ( hub2 => {
40+ runWithAsyncContext ( ( ) => {
41+ const hub2 = getCurrentHub ( ) ;
3842 expect ( hub2 ) . toEqual ( hub1 ) ;
3943 expect ( hub2 ) . not . toEqual ( globalHub ) ;
4044
@@ -59,13 +63,15 @@ conditionalTest({ min: 12 })('async_hooks', () => {
5963 const globalHub = getCurrentHub ( ) ;
6064 await addRandomExtra ( globalHub , 'a' ) ;
6165
62- await runWithAsyncContext ( async hub1 => {
66+ await runWithAsyncContext ( async ( ) => {
67+ const hub1 = getCurrentHub ( ) ;
6368 expect ( hub1 ) . toEqual ( globalHub ) ;
6469
6570 await addRandomExtra ( hub1 , 'b' ) ;
6671 expect ( hub1 ) . not . toEqual ( globalHub ) ;
6772
68- await runWithAsyncContext ( async hub2 => {
73+ await runWithAsyncContext ( async ( ) => {
74+ const hub2 = getCurrentHub ( ) ;
6975 expect ( hub2 ) . toEqual ( hub1 ) ;
7076 expect ( hub2 ) . not . toEqual ( globalHub ) ;
7177
@@ -78,16 +84,19 @@ conditionalTest({ min: 12 })('async_hooks', () => {
7884 test ( 'context single instance' , ( ) => {
7985 setHooksAsyncContextStrategy ( ) ;
8086
81- runWithAsyncContext ( hub => {
82- expect ( hub ) . toBe ( getCurrentHub ( ) ) ;
87+ const globalHub = getCurrentHub ( ) ;
88+ runWithAsyncContext ( ( ) => {
89+ expect ( globalHub ) . not . toBe ( getCurrentHub ( ) ) ;
8390 } ) ;
8491 } ) ;
8592
8693 test ( 'context within a context not reused' , ( ) => {
8794 setHooksAsyncContextStrategy ( ) ;
8895
89- runWithAsyncContext ( hub1 => {
90- runWithAsyncContext ( hub2 => {
96+ runWithAsyncContext ( ( ) => {
97+ const hub1 = getCurrentHub ( ) ;
98+ runWithAsyncContext ( ( ) => {
99+ const hub2 = getCurrentHub ( ) ;
91100 expect ( hub1 ) . not . toBe ( hub2 ) ;
92101 } ) ;
93102 } ) ;
@@ -96,9 +105,11 @@ conditionalTest({ min: 12 })('async_hooks', () => {
96105 test ( 'context within a context reused when requested' , ( ) => {
97106 setHooksAsyncContextStrategy ( ) ;
98107
99- runWithAsyncContext ( hub1 => {
108+ runWithAsyncContext ( ( ) => {
109+ const hub1 = getCurrentHub ( ) ;
100110 runWithAsyncContext (
101- hub2 => {
111+ ( ) => {
112+ const hub2 = getCurrentHub ( ) ;
102113 expect ( hub1 ) . toBe ( hub2 ) ;
103114 } ,
104115 { reuseExisting : true } ,
@@ -112,7 +123,8 @@ conditionalTest({ min: 12 })('async_hooks', () => {
112123 let d1done = false ;
113124 let d2done = false ;
114125
115- runWithAsyncContext ( hub => {
126+ runWithAsyncContext ( ( ) => {
127+ const hub = getCurrentHub ( ) ;
116128 hub . getStack ( ) . push ( { client : 'process' } as any ) ;
117129 expect ( hub . getStack ( ) [ 1 ] ) . toEqual ( { client : 'process' } ) ;
118130 // Just in case so we don't have to worry which one finishes first
@@ -125,7 +137,8 @@ conditionalTest({ min: 12 })('async_hooks', () => {
125137 } ) ;
126138 } ) ;
127139
128- runWithAsyncContext ( hub => {
140+ runWithAsyncContext ( ( ) => {
141+ const hub = getCurrentHub ( ) ;
129142 hub . getStack ( ) . push ( { client : 'local' } as any ) ;
130143 expect ( hub . getStack ( ) [ 1 ] ) . toEqual ( { client : 'local' } ) ;
131144 setTimeout ( ( ) => {
0 commit comments