@@ -3,8 +3,11 @@ import { waitForError, waitForTransaction } from '@sentry-internal/event-proxy-s
3
3
4
4
test ( 'Should create a transaction for route handlers' , async ( { request } ) => {
5
5
const routehandlerTransactionPromise = waitForTransaction ( 'nextjs-13-app-dir' , async transactionEvent => {
6
- console . log ( 'transactionEvent1' , JSON . stringify ( transactionEvent , null , 2 ) ) ;
7
- return transactionEvent ?. transaction === 'GET /route-handlers/[param]' ;
6
+ // Sometimes, next.js adds /route there, we accept both variants
7
+ return (
8
+ transactionEvent ?. transaction === 'GET /route-handlers/[param]' ||
9
+ transactionEvent ?. transaction === 'GET /route-handlers/[param]/route'
10
+ ) ;
8
11
} ) ;
9
12
10
13
const response = await request . get ( '/route-handlers/foo' , { headers : { 'x-yeet' : 'test-value' } } ) ;
@@ -21,8 +24,11 @@ test('Should create a transaction for route handlers and correctly set span stat
21
24
request,
22
25
} ) => {
23
26
const routehandlerTransactionPromise = waitForTransaction ( 'nextjs-13-app-dir' , async transactionEvent => {
24
- console . log ( 'transactionEvent2' , JSON . stringify ( transactionEvent , null , 2 ) ) ;
25
- return transactionEvent ?. transaction === 'POST /route-handlers/[param]' ;
27
+ // Sometimes, next.js adds /route there, we accept both variants
28
+ return (
29
+ transactionEvent ?. transaction === 'POST /route-handlers/[param]' ||
30
+ transactionEvent ?. transaction === 'POST /route-handlers/[param]/route'
31
+ ) ;
26
32
} ) ;
27
33
28
34
const response = await request . post ( '/route-handlers/bar' ) ;
@@ -41,7 +47,11 @@ test('Should record exceptions and transactions for faulty route handlers', asyn
41
47
42
48
const routehandlerTransactionPromise = waitForTransaction ( 'nextjs-13-app-dir' , async transactionEvent => {
43
49
console . log ( 'transactionEvent3' , JSON . stringify ( transactionEvent , null , 2 ) ) ;
44
- return transactionEvent ?. transaction === 'PUT /route-handlers/[param]/error' ;
50
+ // Sometimes, next.js adds /route there, we accept both variants
51
+ return (
52
+ transactionEvent ?. transaction === 'PUT /route-handlers/[param]' ||
53
+ transactionEvent ?. transaction === 'PUT /route-handlers/[param]/route'
54
+ ) ;
45
55
} ) ;
46
56
47
57
await request . put ( '/route-handlers/baz/error' ) . catch ( ( ) => {
0 commit comments