11import { expect , test } from '@playwright/test' ;
2- import { waitForError } from '@sentry-internal/event-proxy-server' ;
2+ import { waitForError , waitForTransaction } from '@sentry-internal/event-proxy-server' ;
33
44test ( 'Sends thrown error to Sentry' , async ( { baseURL } ) => {
55 const errorEventPromise = waitForError ( 'node-hapi' , errorEvent => {
66 return errorEvent ?. exception ?. values ?. [ 0 ] ?. value === 'This is an error' ;
77 } ) ;
88
9+ const transactionEventPromise = waitForTransaction ( 'node-hapi' , transactionEvent => {
10+ return transactionEvent ?. transaction === 'GET /test-failure' ;
11+ } ) ;
12+
913 await fetch ( `${ baseURL } /test-failure` ) ;
1014
1115 const errorEvent = await errorEventPromise ;
12- const errorEventId = errorEvent . event_id ;
16+ const transactionEvent = await transactionEventPromise ;
17+
18+ expect ( transactionEvent . transaction ) . toBe ( 'GET /test-failure' ) ;
19+ expect ( transactionEvent . contexts ?. trace ) . toMatchObject ( {
20+ trace_id : expect . any ( String ) ,
21+ span_id : expect . any ( String ) ,
22+ } ) ;
23+ console . debug ( 'transactionEvent' , transactionEvent ) ;
1324
1425 expect ( errorEvent . exception ?. values ) . toHaveLength ( 1 ) ;
1526 expect ( errorEvent . exception ?. values ?. [ 0 ] ?. value ) . toBe ( 'This is an error' ) ;
@@ -27,6 +38,9 @@ test('Sends thrown error to Sentry', async ({ baseURL }) => {
2738 trace_id : expect . any ( String ) ,
2839 span_id : expect . any ( String ) ,
2940 } ) ;
41+
42+ expect ( errorEvent . contexts ?. trace ?. trace_id ) . toBe ( transactionEvent . contexts ?. trace ?. trace_id ) ;
43+ expect ( errorEvent . contexts ?. trace ?. span_id ) . toBe ( transactionEvent . contexts ?. trace ?. span_id ) ;
3044} ) ;
3145
3246test ( 'sends error with parameterized transaction name' , async ( { baseURL } ) => {
0 commit comments