Skip to content

Commit 9f29bfc

Browse files
committed
add failing e2e test
1 parent 2c45b73 commit 9f29bfc

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { createFileRoute } from '@tanstack/react-router';
2+
3+
export const Route = createFileRoute('/api/hello')({
4+
server: {
5+
handlers: {
6+
GET: async () => {
7+
return new Response('Hello, world!');
8+
},
9+
},
10+
},
11+
});

dev-packages/e2e-tests/test-applications/tanstackstart-react/tests/transaction.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,40 @@ test('Sends a server function transaction for a nested server function only if i
9898
expect(nestedSpan).toBeDefined();
9999
expect(nestedSpan?.parent_span_id).toBe(autoSpan?.span_id);
100100
});
101+
102+
test('Sends an API route transaction with auto-instrumentation', async ({ page }) => {
103+
const transactionEventPromise = waitForTransaction('tanstackstart-react', transactionEvent => {
104+
return (
105+
transactionEvent?.contexts?.trace?.op === 'http.server' &&
106+
transactionEvent?.transaction === 'GET /api/hello'
107+
);
108+
});
109+
110+
await page.goto('/api/hello');
111+
112+
const transactionEvent = await transactionEventPromise;
113+
114+
console.log('transactionEvent: ', transactionEvent);
115+
116+
expect(transactionEvent).toEqual(
117+
expect.objectContaining({
118+
transaction: 'GET /api/hello',
119+
}),
120+
);
121+
122+
expect(transactionEvent?.spans).toEqual(
123+
expect.arrayContaining([
124+
expect.objectContaining({
125+
description: 'GET /api/hello',
126+
op: 'http.server',
127+
origin: 'auto.http.tanstackstart.server',
128+
source: 'route',
129+
data: {
130+
'sentry.op': 'http.server',
131+
'sentry.origin': 'auto.http.tanstackstart.server',
132+
'http.route': '/api/hello',
133+
},
134+
}),
135+
]),
136+
);
137+
});

0 commit comments

Comments
 (0)