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+ } ) ;
1323
1424 expect ( errorEvent . exception ?. values ) . toHaveLength ( 1 ) ;
1525 expect ( errorEvent . exception ?. values ?. [ 0 ] ?. value ) . toBe ( 'This is an error' ) ;
@@ -27,6 +37,9 @@ test('Sends thrown error to Sentry', async ({ baseURL }) => {
2737 trace_id : expect . any ( String ) ,
2838 span_id : expect . any ( String ) ,
2939 } ) ;
40+
41+ expect ( errorEvent . contexts ?. trace ?. trace_id ) . toBe ( transactionEvent . contexts ?. trace ?. trace_id ) ;
42+ expect ( errorEvent . contexts ?. trace ?. span_id ) . toBe ( transactionEvent . contexts ?. trace ?. span_id ) ;
3043} ) ;
3144
3245test ( 'sends error with parameterized transaction name' , async ( { baseURL } ) => {
0 commit comments