@@ -121,16 +121,20 @@ describe('Hub', () => {
121
121
} ) ;
122
122
123
123
describe ( 'withScope' , ( ) => {
124
+ let hub : Hub ;
125
+
126
+ beforeEach ( ( ) => {
127
+ hub = new Hub ( ) ;
128
+ } ) ;
129
+
124
130
test ( 'simple' , ( ) => {
125
- const hub = new Hub ( ) ;
126
131
hub . withScope ( ( ) => {
127
132
expect ( hub . getStack ( ) ) . toHaveLength ( 2 ) ;
128
133
} ) ;
129
134
expect ( hub . getStack ( ) ) . toHaveLength ( 1 ) ;
130
135
} ) ;
131
136
132
137
test ( 'bindClient' , ( ) => {
133
- const hub = new Hub ( ) ;
134
138
const testClient : any = { bla : 'a' } ;
135
139
hub . withScope ( ( ) => {
136
140
hub . bindClient ( testClient ) ;
@@ -139,6 +143,15 @@ describe('Hub', () => {
139
143
} ) ;
140
144
expect ( hub . getStack ( ) ) . toHaveLength ( 1 ) ;
141
145
} ) ;
146
+
147
+ test ( 'should bubble up exceptions' , ( ) => {
148
+ const error = new Error ( 'test' ) ;
149
+ expect ( ( ) => {
150
+ hub . withScope ( ( ) => {
151
+ throw error ;
152
+ } ) ;
153
+ } ) . toThrow ( error ) ;
154
+ } ) ;
142
155
} ) ;
143
156
144
157
test ( 'getCurrentClient' , ( ) => {
@@ -277,18 +290,30 @@ describe('Hub', () => {
277
290
expect ( eventId ) . toBe ( hub . lastEventId ( ) ) ;
278
291
} ) ;
279
292
280
- test ( 'run' , ( ) => {
281
- const currentHub = getCurrentHub ( ) ;
282
- const myScope = new Scope ( ) ;
283
- const myClient : any = { a : 'b' } ;
284
- myScope . setExtra ( 'a' , 'b' ) ;
285
- const myHub = new Hub ( myClient , myScope ) ;
286
- myHub . run ( hub => {
287
- expect ( hub . getScope ( ) ) . toBe ( myScope ) ;
288
- expect ( hub . getClient ( ) ) . toBe ( myClient ) ;
289
- expect ( hub ) . toBe ( getCurrentHub ( ) ) ;
293
+ describe ( 'run' , ( ) => {
294
+ test ( 'simple' , ( ) => {
295
+ const currentHub = getCurrentHub ( ) ;
296
+ const myScope = new Scope ( ) ;
297
+ const myClient : any = { a : 'b' } ;
298
+ myScope . setExtra ( 'a' , 'b' ) ;
299
+ const myHub = new Hub ( myClient , myScope ) ;
300
+ myHub . run ( hub => {
301
+ expect ( hub . getScope ( ) ) . toBe ( myScope ) ;
302
+ expect ( hub . getClient ( ) ) . toBe ( myClient ) ;
303
+ expect ( hub ) . toBe ( getCurrentHub ( ) ) ;
304
+ } ) ;
305
+ expect ( currentHub ) . toBe ( getCurrentHub ( ) ) ;
306
+ } ) ;
307
+
308
+ test ( 'should bubble up exceptions' , ( ) => {
309
+ const hub = new Hub ( ) ;
310
+ const error = new Error ( 'test' ) ;
311
+ expect ( ( ) => {
312
+ hub . run ( ( ) => {
313
+ throw error ;
314
+ } ) ;
315
+ } ) . toThrow ( error ) ;
290
316
} ) ;
291
- expect ( currentHub ) . toBe ( getCurrentHub ( ) ) ;
292
317
} ) ;
293
318
294
319
describe ( 'breadcrumbs' , ( ) => {
0 commit comments