@@ -4,16 +4,30 @@ import type { Event } from '@sentry/types';
44import { sentryTest } from '../../../../utils/fixtures' ;
55import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers' ;
66
7- sentryTest ( 'scope is applied to thrown error' , async ( { getLocalTestPath, page } ) => {
8- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
7+ /**
8+ * Why does this test exist?
9+ *
10+ * We recently discovered that errors caught by global handlers will potentially loose scope data from the active scope
11+ * where the error was thrown in. The simple example in this test (see subject.ts) demonstrates this behavior (in a
12+ * browser environment but the same behavior applies to the server; see the test there).
13+ *
14+ * This test nevertheless covers the behavior so that we're aware.
15+ */
16+ sentryTest (
17+ 'withScope scope is NOT applied to thrown error caught by global handler' ,
18+ async ( { getLocalTestPath, page } ) => {
19+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
920
10- const eventData = await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
21+ const eventData = await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
1122
12- const ex = eventData . exception ?. values ? eventData . exception . values [ 0 ] : undefined ;
23+ const ex = eventData . exception ?. values ? eventData . exception . values [ 0 ] : undefined ;
1324
14- expect ( eventData . tags ) . toMatchObject ( {
15- global : 'tag' ,
16- local : 'tag' , // this tag is missing :(
17- } ) ;
18- expect ( ex ?. value ) . toBe ( 'test error' ) ;
19- } ) ;
25+ // This tag is missing :(
26+ expect ( eventData . tags ?. local ) . toBeUndefined ( ) ;
27+
28+ expect ( eventData . tags ) . toMatchObject ( {
29+ global : 'tag' ,
30+ } ) ;
31+ expect ( ex ?. value ) . toBe ( 'test error' ) ;
32+ } ,
33+ ) ;
0 commit comments