Skip to content

Commit 427fa20

Browse files
author
Luca Forstner
authored
test(e2e): Add request instrumentation tests for Next.js 14 (#10367)
1 parent 6b3f553 commit 427fa20

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import http from 'http';
2+
3+
export const dynamic = 'force-dynamic';
4+
5+
export default async function Page() {
6+
await fetch('http://example.com/');
7+
await new Promise<void>(resolve => {
8+
http.get('http://example.com/', () => {
9+
resolve();
10+
});
11+
});
12+
return <p>Hello World!</p>;
13+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { expect, test } from '@playwright/test';
2+
import { waitForTransaction } from '../event-proxy-server';
3+
4+
test('Should send a transaction with a fetch span', async ({ page }) => {
5+
const transactionPromise = waitForTransaction('nextjs-14', async transactionEvent => {
6+
return transactionEvent?.transaction === 'Page Server Component (/request-instrumentation)';
7+
});
8+
9+
await page.goto(`/request-instrumentation`);
10+
11+
expect((await transactionPromise).spans).toContainEqual(
12+
expect.objectContaining({
13+
data: expect.objectContaining({
14+
'http.method': 'GET',
15+
'sentry.op': 'http.client',
16+
'sentry.origin': 'auto.http.node.undici',
17+
}),
18+
description: 'GET http://example.com/',
19+
}),
20+
);
21+
22+
expect((await transactionPromise).spans).toContainEqual(
23+
expect.objectContaining({
24+
data: expect.objectContaining({
25+
'http.method': 'GET',
26+
'sentry.op': 'http.client',
27+
'sentry.origin': 'auto.http.node.http',
28+
}),
29+
description: 'GET http://example.com/',
30+
}),
31+
);
32+
});

0 commit comments

Comments
 (0)