1
1
import { expect } from '@playwright/test' ;
2
- import type { Event } from '@sentry/types ' ;
2
+ import { SDK_VERSION } from '@sentry/browser ' ;
3
3
4
4
import { sentryTest } from '../../../../utils/fixtures' ;
5
- import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers' ;
5
+ import { envelopeRequestParser , waitForErrorRequestOnUrl } from '../../../../utils/helpers' ;
6
6
7
- sentryTest ( 'should capture a simple error with message' , async ( { getLocalTestPath , page } ) => {
8
- const url = await getLocalTestPath ( { testDir : __dirname } ) ;
9
-
10
- const eventData = await getFirstSentryEnvelopeRequest < Event > ( page , url ) ;
7
+ sentryTest ( 'should capture a simple error with message' , async ( { getLocalTestUrl , page } ) => {
8
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
9
+ const req = await waitForErrorRequestOnUrl ( page , url ) ;
10
+ const eventData = envelopeRequestParser ( req ) ;
11
11
12
12
expect ( eventData . exception ?. values ) . toHaveLength ( 1 ) ;
13
13
expect ( eventData . exception ?. values ?. [ 0 ] ) . toMatchObject ( {
@@ -22,3 +22,23 @@ sentryTest('should capture a simple error with message', async ({ getLocalTestPa
22
22
} ,
23
23
} ) ;
24
24
} ) ;
25
+
26
+ sentryTest ( 'should capture a correct SDK metadata' , async ( { getLocalTestUrl, page } ) => {
27
+ const isCdn = ( process . env . PW_BUNDLE || '' ) . startsWith ( 'bundle' ) ;
28
+
29
+ const url = await getLocalTestUrl ( { testDir : __dirname } ) ;
30
+ const req = await waitForErrorRequestOnUrl ( page , url ) ;
31
+ const eventData = envelopeRequestParser ( req ) ;
32
+
33
+ expect ( eventData . sdk ) . toEqual ( {
34
+ name : 'sentry.javascript.browser' ,
35
+ version : SDK_VERSION ,
36
+ integrations : expect . any ( Object ) ,
37
+ packages : [
38
+ {
39
+ name : `${ isCdn ? 'cdn' : 'npm' } :@sentry/browser` ,
40
+ version : SDK_VERSION ,
41
+ } ,
42
+ ] ,
43
+ } ) ;
44
+ } ) ;
0 commit comments