1
1
import { expect , test } from '@playwright/test' ;
2
- import { waitForError } from '@sentry-internal/event-proxy-server' ;
2
+ import { waitForError , waitForTransaction } from '@sentry-internal/event-proxy-server' ;
3
3
4
4
test ( 'Sends thrown error to Sentry' , async ( { baseURL } ) => {
5
5
const errorEventPromise = waitForError ( 'node-hapi' , errorEvent => {
6
6
return errorEvent ?. exception ?. values ?. [ 0 ] ?. value === 'This is an error' ;
7
7
} ) ;
8
8
9
+ const transactionEventPromise = waitForTransaction ( 'node-hapi' , transactionEvent => {
10
+ return transactionEvent ?. transaction === 'GET /test-failure' ;
11
+ } ) ;
12
+
9
13
await fetch ( `${ baseURL } /test-failure` ) ;
10
14
11
15
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
+ } ) ;
13
23
14
24
expect ( errorEvent . exception ?. values ) . toHaveLength ( 1 ) ;
15
25
expect ( errorEvent . exception ?. values ?. [ 0 ] ?. value ) . toBe ( 'This is an error' ) ;
@@ -27,6 +37,9 @@ test('Sends thrown error to Sentry', async ({ baseURL }) => {
27
37
trace_id : expect . any ( String ) ,
28
38
span_id : expect . any ( String ) ,
29
39
} ) ;
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 ) ;
30
43
} ) ;
31
44
32
45
test ( 'sends error with parameterized transaction name' , async ( { baseURL } ) => {
0 commit comments