@@ -3,14 +3,12 @@ import { waitForError, waitForTransaction } from '@sentry-internal/event-proxy-s
3
3
import { createTRPCProxyClient , httpBatchLink } from '@trpc/client' ;
4
4
import type { AppRouter } from '../src/app' ;
5
5
6
- const authToken = process . env . E2E_TEST_AUTH_TOKEN ;
7
- const sentryTestOrgSlug = process . env . E2E_TEST_SENTRY_ORG_SLUG ;
8
- const sentryTestProject = process . env . E2E_TEST_SENTRY_TEST_PROJECT ;
9
- const EVENT_POLLING_TIMEOUT = 90_000 ;
10
-
11
- test ( 'Should record transaction for trpc query' , async ( { baseURL } ) => {
6
+ test ( 'Should record span for trpc query' , async ( { baseURL } ) => {
12
7
const transactionEventPromise = waitForTransaction ( 'node-express-app' , transactionEvent => {
13
- return transactionEvent . transaction === 'trpc/getSomething' ;
8
+ return (
9
+ transactionEvent . transaction === 'GET /trpc' &&
10
+ ! ! transactionEvent . spans ?. find ( span => span . description === 'trpc/getSomething' )
11
+ ) ;
14
12
} ) ;
15
13
16
14
const trpcClient = createTRPCProxyClient < AppRouter > ( {
@@ -26,6 +24,16 @@ test('Should record transaction for trpc query', async ({ baseURL }) => {
26
24
await expect ( transactionEventPromise ) . resolves . toBeDefined ( ) ;
27
25
const transaction = await transactionEventPromise ;
28
26
27
+ expect ( transaction . spans ) . toContainEqual (
28
+ expect . objectContaining ( {
29
+ data : expect . objectContaining ( {
30
+ 'sentry.op' : 'rpc.server' ,
31
+ 'sentry.origin' : 'auto.rpc.trpc' ,
32
+ } ) ,
33
+ description : `trpc/getSomething` ,
34
+ } ) ,
35
+ ) ;
36
+
29
37
expect ( transaction . contexts ?. trpc ) . toMatchObject ( {
30
38
procedure_type : 'query' ,
31
39
input : 'foobar' ,
@@ -34,7 +42,10 @@ test('Should record transaction for trpc query', async ({ baseURL }) => {
34
42
35
43
test ( 'Should record transaction for trpc mutation' , async ( { baseURL } ) => {
36
44
const transactionEventPromise = waitForTransaction ( 'node-express-app' , transactionEvent => {
37
- return transactionEvent . transaction === 'trpc/createSomething' ;
45
+ return (
46
+ transactionEvent . transaction === 'POST /trpc' &&
47
+ ! ! transactionEvent . spans ?. find ( span => span . description === 'trpc/createSomething' )
48
+ ) ;
38
49
} ) ;
39
50
40
51
const trpcClient = createTRPCProxyClient < AppRouter > ( {
@@ -50,14 +61,27 @@ test('Should record transaction for trpc mutation', async ({ baseURL }) => {
50
61
await expect ( transactionEventPromise ) . resolves . toBeDefined ( ) ;
51
62
const transaction = await transactionEventPromise ;
52
63
64
+ expect ( transaction . spans ) . toContainEqual (
65
+ expect . objectContaining ( {
66
+ data : expect . objectContaining ( {
67
+ 'sentry.op' : 'rpc.server' ,
68
+ 'sentry.origin' : 'auto.rpc.trpc' ,
69
+ } ) ,
70
+ description : `trpc/createSomething` ,
71
+ } ) ,
72
+ ) ;
73
+
53
74
expect ( transaction . contexts ?. trpc ) . toMatchObject ( {
54
75
procedure_type : 'mutation' ,
55
76
} ) ;
56
77
} ) ;
57
78
58
79
test ( 'Should record transaction and error for a crashing trpc handler' , async ( { baseURL } ) => {
59
80
const transactionEventPromise = waitForTransaction ( 'node-express-app' , transactionEvent => {
60
- return transactionEvent . transaction === 'trpc/crashSomething' ;
81
+ return (
82
+ transactionEvent . transaction === 'POST /trpc' &&
83
+ ! ! transactionEvent . spans ?. find ( span => span . description === 'trpc/crashSomething' )
84
+ ) ;
61
85
} ) ;
62
86
63
87
const errorEventPromise = waitForError ( 'node-express-app' , errorEvent => {
@@ -80,7 +104,10 @@ test('Should record transaction and error for a crashing trpc handler', async ({
80
104
81
105
test ( 'Should record transaction and error for a trpc handler that returns a status code' , async ( { baseURL } ) => {
82
106
const transactionEventPromise = waitForTransaction ( 'node-express-app' , transactionEvent => {
83
- return transactionEvent . transaction === 'trpc/dontFindSomething' ;
107
+ return (
108
+ transactionEvent . transaction === 'POST /trpc' &&
109
+ ! ! transactionEvent . spans ?. find ( span => span . description === 'trpc/dontFindSomething' )
110
+ ) ;
84
111
} ) ;
85
112
86
113
const errorEventPromise = waitForError ( 'node-express-app' , errorEvent => {
0 commit comments