Skip to content

Commit 57c7026

Browse files
author
Luca Forstner
committed
Move test to e2e
1 parent d39e169 commit 57c7026

File tree

6 files changed

+37
-29
lines changed

6 files changed

+37
-29
lines changed

dev-packages/e2e-tests/test-applications/nextjs-14/instrumentation.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export function register() {
88
tunnel: `http://localhost:3031/`, // proxy server
99
tracesSampleRate: 1.0,
1010
sendDefaultPii: true,
11-
debug: true,
1211
transportOptions: {
1312
// We are doing a lot of events at once in this test
1413
bufferSize: 1000,

dev-packages/e2e-tests/test-applications/nextjs-app-dir/instrumentation.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export function register() {
88
tunnel: `http://localhost:3031/`, // proxy server
99
tracesSampleRate: 1.0,
1010
sendDefaultPii: true,
11-
debug: true,
1211
transportOptions: {
1312
// We are doing a lot of events at once in this test
1413
bufferSize: 1000,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { get } from 'http';
2+
import { NextApiRequest, NextApiResponse } from 'next';
3+
4+
export default (_req: NextApiRequest, res: NextApiResponse) => {
5+
// make an outgoing request in order to test that the `Http` integration creates a span
6+
get('http://example.com/', message => {
7+
message.on('data', () => {
8+
// Noop consuming some data so that request can close :)
9+
});
10+
11+
message.on('close', () => {
12+
res.status(200).json({});
13+
});
14+
});
15+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 ({ request }) => {
5+
const transactionPromise = waitForTransaction('nextjs-13-app-dir', async transactionEvent => {
6+
return transactionEvent?.transaction === 'GET /api/request-instrumentation';
7+
});
8+
9+
await request.get('/api/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.otel.http',
17+
}),
18+
description: 'GET http://example.com/',
19+
}),
20+
);
21+
});
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
import { get } from 'http';
21
import { NextApiRequest, NextApiResponse } from 'next';
32

43
export default (_req: NextApiRequest, res: NextApiResponse) => {
5-
// make an outgoing request in order to test that the `Http` integration creates a span
6-
get('http://example.com/', message => {
7-
message.on('data', () => {
8-
// Noop consuming some data so that request can close :)
9-
});
10-
11-
message.on('close', () => {
12-
setTimeout(() => {
13-
res.status(200).json({});
14-
}, 1000);
15-
});
16-
});
4+
res.status(200).json({});
175
};

packages/nextjs/test/integration/test/server/tracingHttp.test.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
import nock from 'nock';
21
import { NextTestEnv } from './utils/helpers';
32

43
describe('Tracing HTTP', () => {
54
it('should capture a transaction', async () => {
65
const env = await NextTestEnv.init();
76
const url = `${env.url}/api/http`;
87

9-
// this intercepts the outgoing request made by the route handler (which it makes in order to test span creation)
10-
nock('http://example.com/').get('/').reply(200, 'ok');
11-
128
const envelopes = await env.getMultipleEnvelopeRequest({
139
url,
1410
envelopeType: 'transaction',
@@ -34,16 +30,6 @@ describe('Tracing HTTP', () => {
3430
},
3531
},
3632
},
37-
spans: [
38-
{
39-
description: 'GET http://example.com/',
40-
op: 'http.client',
41-
status: 'ok',
42-
data: {
43-
'http.response.status_code': 200,
44-
},
45-
},
46-
],
4733
transaction: 'GET /api/http',
4834
transaction_info: {
4935
source: 'route',

0 commit comments

Comments
 (0)