Skip to content

Commit dcc30df

Browse files
committed
fix tests
1 parent f2ca1e7 commit dcc30df

File tree

10 files changed

+44
-127
lines changed

10 files changed

+44
-127
lines changed

dev-packages/e2e-tests/test-applications/node-express-v5/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "node-expres-v5-app",
2+
"name": "node-express-v5-app",
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {

dev-packages/e2e-tests/test-applications/node-express-v5/src/app.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,10 @@ app.get('/test-param/:param', function (req, res) {
5252
res.send({ paramWas: req.params.param });
5353
});
5454

55-
app.get('/test-transaction', function (req, res) {
56-
Sentry.withActiveSpan(null, async () => {
57-
Sentry.startSpan({ name: 'test-transaction', op: 'e2e-test' }, () => {
58-
Sentry.startSpan({ name: 'test-span' }, () => undefined);
59-
});
60-
61-
await Sentry.flush();
55+
app.get('/test-transaction', function (_req, res) {
56+
Sentry.startSpan({ name: 'test-span' }, () => undefined);
6257

63-
res.send({
64-
transactionIds: global.transactionIds || [],
65-
});
66-
});
58+
res.send({ status: 'ok' });
6759
});
6860

6961
app.get('/test-error', async function (req, res) {

dev-packages/e2e-tests/test-applications/node-express-v5/start-event-proxy.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { startEventProxyServer } from '@sentry-internal/test-utils';
22

33
startEventProxyServer({
44
port: 3031,
5-
proxyServerName: 'node-expres-v5',
5+
proxyServerName: 'node-express-v5',
66
});

dev-packages/e2e-tests/test-applications/node-express-v5/tests/errors.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
22
import { waitForError } from '@sentry-internal/test-utils';
33

44
test('Sends correct error event', async ({ baseURL }) => {
5-
const errorEventPromise = waitForError('node-expres-v5', event => {
5+
const errorEventPromise = waitForError('node-express-v5', event => {
66
return !event.type && event.exception?.values?.[0]?.value === 'This is an exception with id 123';
77
});
88

@@ -29,7 +29,7 @@ test('Sends correct error event', async ({ baseURL }) => {
2929
});
3030

3131
test('Should record caught exceptions with local variable', async ({ baseURL }) => {
32-
const errorEventPromise = waitForError('node-expres-v5', event => {
32+
const errorEventPromise = waitForError('node-express-v5', event => {
3333
return event.transaction === 'GET /test-local-variables-caught';
3434
});
3535

dev-packages/e2e-tests/test-applications/node-express-v5/tests/logs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { waitForEnvelopeItem } from '@sentry-internal/test-utils';
33
import type { SerializedLogContainer } from '@sentry/core';
44

55
test('should send logs', async ({ baseURL }) => {
6-
const logEnvelopePromise = waitForEnvelopeItem('node-expres-v5', envelope => {
6+
const logEnvelopePromise = waitForEnvelopeItem('node-express-v5', envelope => {
77
return envelope[0].type === 'log' && (envelope[1] as SerializedLogContainer).items[0]?.level === 'debug';
88
});
99

dev-packages/e2e-tests/test-applications/node-express-v5/tests/mcp.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ test('Should record transactions for mcp handlers', async ({ baseURL }) => {
1414
await client.connect(transport);
1515

1616
await test.step('tool handler', async () => {
17-
const postTransactionPromise = waitForTransaction('node-expres-v5', transactionEvent => {
17+
const postTransactionPromise = waitForTransaction('node-express-v5', transactionEvent => {
1818
return transactionEvent.transaction === 'POST /messages';
1919
});
20-
const toolTransactionPromise = waitForTransaction('node-expres-v5', transactionEvent => {
20+
const toolTransactionPromise = waitForTransaction('node-express-v5', transactionEvent => {
2121
return transactionEvent.transaction === 'mcp-server/tool:echo';
2222
});
2323

@@ -47,10 +47,10 @@ test('Should record transactions for mcp handlers', async ({ baseURL }) => {
4747
});
4848

4949
await test.step('resource handler', async () => {
50-
const postTransactionPromise = waitForTransaction('node-expres-v5', transactionEvent => {
50+
const postTransactionPromise = waitForTransaction('node-express-v5', transactionEvent => {
5151
return transactionEvent.transaction === 'POST /messages';
5252
});
53-
const resourceTransactionPromise = waitForTransaction('node-expres-v5', transactionEvent => {
53+
const resourceTransactionPromise = waitForTransaction('node-express-v5', transactionEvent => {
5454
return transactionEvent.transaction === 'mcp-server/resource:echo';
5555
});
5656

@@ -72,10 +72,10 @@ test('Should record transactions for mcp handlers', async ({ baseURL }) => {
7272
});
7373

7474
await test.step('prompt handler', async () => {
75-
const postTransactionPromise = waitForTransaction('node-expres-v5', transactionEvent => {
75+
const postTransactionPromise = waitForTransaction('node-express-v5', transactionEvent => {
7676
return transactionEvent.transaction === 'POST /messages';
7777
});
78-
const promptTransactionPromise = waitForTransaction('node-expres-v5', transactionEvent => {
78+
const promptTransactionPromise = waitForTransaction('node-express-v5', transactionEvent => {
7979
return transactionEvent.transaction === 'mcp-server/prompt:echo';
8080
});
8181

dev-packages/e2e-tests/test-applications/node-express-v5/tests/transactions.test.ts

Lines changed: 7 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from '@playwright/test';
22
import { waitForTransaction } from '@sentry-internal/test-utils';
33

44
test('Sends an API route transaction', async ({ baseURL }) => {
5-
const pageloadTransactionEventPromise = waitForTransaction('node-expres-v5', transactionEvent => {
5+
const pageloadTransactionEventPromise = waitForTransaction('node-express-v5', transactionEvent => {
66
return (
77
transactionEvent?.contexts?.trace?.op === 'http.server' &&
88
transactionEvent?.transaction === 'GET /test-transaction'
@@ -62,34 +62,11 @@ test('Sends an API route transaction', async ({ baseURL }) => {
6262

6363
const spans = transactionEvent.spans || [];
6464

65+
// Manually started span
6566
expect(spans).toContainEqual({
66-
data: {
67-
'sentry.origin': 'auto.http.otel.express',
68-
'sentry.op': 'middleware.express',
69-
'express.name': 'query',
70-
'express.type': 'middleware',
71-
},
72-
description: 'query',
73-
op: 'middleware.express',
74-
origin: 'auto.http.otel.express',
75-
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
76-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
77-
start_timestamp: expect.any(Number),
78-
status: 'ok',
79-
timestamp: expect.any(Number),
80-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
81-
});
82-
83-
expect(spans).toContainEqual({
84-
data: {
85-
'sentry.origin': 'auto.http.otel.express',
86-
'sentry.op': 'middleware.express',
87-
'express.name': 'expressInit',
88-
'express.type': 'middleware',
89-
},
90-
description: 'expressInit',
91-
op: 'middleware.express',
92-
origin: 'auto.http.otel.express',
67+
data: { 'sentry.origin': 'manual' },
68+
description: 'test-span',
69+
origin: 'manual',
9370
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
9471
span_id: expect.stringMatching(/[a-f0-9]{16}/),
9572
start_timestamp: expect.any(Number),
@@ -98,6 +75,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
9875
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
9976
});
10077

78+
// auto instrumented span
10179
expect(spans).toContainEqual({
10280
data: {
10381
'sentry.origin': 'auto.http.otel.express',
@@ -119,7 +97,7 @@ test('Sends an API route transaction', async ({ baseURL }) => {
11997
});
12098

12199
test('Sends an API route transaction for an errored route', async ({ baseURL }) => {
122-
const transactionEventPromise = waitForTransaction('node-expres-v5', transactionEvent => {
100+
const transactionEventPromise = waitForTransaction('node-express-v5', transactionEvent => {
123101
return (
124102
transactionEvent.contexts?.trace?.op === 'http.server' &&
125103
transactionEvent.transaction === 'GET /test-exception/:id' &&
@@ -135,62 +113,4 @@ test('Sends an API route transaction for an errored route', async ({ baseURL })
135113
expect(transactionEvent.transaction).toEqual('GET /test-exception/:id');
136114
expect(transactionEvent.contexts?.trace?.status).toEqual('internal_error');
137115
expect(transactionEvent.contexts?.trace?.data?.['http.status_code']).toEqual(500);
138-
139-
const spans = transactionEvent.spans || [];
140-
141-
expect(spans).toContainEqual({
142-
data: {
143-
'sentry.origin': 'auto.http.otel.express',
144-
'sentry.op': 'middleware.express',
145-
'express.name': 'query',
146-
'express.type': 'middleware',
147-
},
148-
description: 'query',
149-
op: 'middleware.express',
150-
origin: 'auto.http.otel.express',
151-
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
152-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
153-
start_timestamp: expect.any(Number),
154-
status: 'ok',
155-
timestamp: expect.any(Number),
156-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
157-
});
158-
159-
expect(spans).toContainEqual({
160-
data: {
161-
'sentry.origin': 'auto.http.otel.express',
162-
'sentry.op': 'middleware.express',
163-
'express.name': 'expressInit',
164-
'express.type': 'middleware',
165-
},
166-
description: 'expressInit',
167-
op: 'middleware.express',
168-
origin: 'auto.http.otel.express',
169-
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
170-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
171-
start_timestamp: expect.any(Number),
172-
status: 'ok',
173-
timestamp: expect.any(Number),
174-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
175-
});
176-
177-
expect(spans).toContainEqual({
178-
data: {
179-
'sentry.origin': 'auto.http.otel.express',
180-
'sentry.op': 'request_handler.express',
181-
'http.route': '/test-exception/:id',
182-
'express.name': '/test-exception/:id',
183-
'express.type': 'request_handler',
184-
},
185-
description: '/test-exception/:id',
186-
op: 'request_handler.express',
187-
origin: 'auto.http.otel.express',
188-
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
189-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
190-
start_timestamp: expect.any(Number),
191-
status: 'unknown_error',
192-
timestamp: expect.any(Number),
193-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
194-
measurements: {},
195-
});
196116
});

dev-packages/e2e-tests/test-applications/node-express-v5/tests/trpc.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
44
import type { AppRouter } from '../src/app';
55

66
test('Should record span for trpc query', async ({ baseURL }) => {
7-
const transactionEventPromise = waitForTransaction('node-expres-v5', transactionEvent => {
7+
const transactionEventPromise = waitForTransaction('node-express-v5', transactionEvent => {
88
return (
99
transactionEvent.transaction === 'GET /trpc' &&
1010
!!transactionEvent.spans?.find(span => span.description === 'trpc/getSomething')
@@ -36,7 +36,7 @@ test('Should record span for trpc query', async ({ baseURL }) => {
3636
});
3737

3838
test('Should record transaction for trpc mutation', async ({ baseURL }) => {
39-
const transactionEventPromise = waitForTransaction('node-expres-v5', transactionEvent => {
39+
const transactionEventPromise = waitForTransaction('node-express-v5', transactionEvent => {
4040
return (
4141
transactionEvent.transaction === 'POST /trpc' &&
4242
!!transactionEvent.spans?.find(span => span.description === 'trpc/createSomething')
@@ -68,14 +68,14 @@ test('Should record transaction for trpc mutation', async ({ baseURL }) => {
6868
});
6969

7070
test('Should record transaction and error for a crashing trpc handler', async ({ baseURL }) => {
71-
const transactionEventPromise = waitForTransaction('node-expres-v5', transactionEvent => {
71+
const transactionEventPromise = waitForTransaction('node-express-v5', transactionEvent => {
7272
return (
7373
transactionEvent.transaction === 'POST /trpc' &&
7474
!!transactionEvent.spans?.find(span => span.description === 'trpc/crashSomething')
7575
);
7676
});
7777

78-
const errorEventPromise = waitForError('node-expres-v5', errorEvent => {
78+
const errorEventPromise = waitForError('node-express-v5', errorEvent => {
7979
return !!errorEvent?.exception?.values?.some(exception => exception.value?.includes('I crashed in a trpc handler'));
8080
});
8181

@@ -106,14 +106,14 @@ test('Should record transaction and error for a crashing trpc handler', async ({
106106
});
107107

108108
test('Should record transaction and error for a trpc handler that returns a status code', async ({ baseURL }) => {
109-
const transactionEventPromise = waitForTransaction('node-expres-v5', transactionEvent => {
109+
const transactionEventPromise = waitForTransaction('node-express-v5', transactionEvent => {
110110
return (
111111
transactionEvent.transaction === 'POST /trpc' &&
112112
!!transactionEvent.spans?.find(span => span.description === 'trpc/badRequest')
113113
);
114114
});
115115

116-
const errorEventPromise = waitForError('node-expres-v5', errorEvent => {
116+
const errorEventPromise = waitForError('node-express-v5', errorEvent => {
117117
return !!errorEvent?.exception?.values?.some(exception => exception.value?.includes('Bad Request'));
118118
});
119119

dev-packages/e2e-tests/test-applications/node-express/src/app.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,11 @@ app.get('/test-param/:param', function (req, res) {
5252
res.send({ paramWas: req.params.param });
5353
});
5454

55-
app.get('/test-transaction', function (req, res) {
56-
Sentry.withActiveSpan(null, async () => {
57-
Sentry.startSpan({ name: 'test-transaction', op: 'e2e-test' }, () => {
58-
Sentry.startSpan({ name: 'test-span' }, () => undefined);
59-
});
60-
61-
await Sentry.flush();
55+
app.get('/test-transaction', function (_req, res) {
56+
Sentry.startSpan({ name: 'test-span' }, () => undefined);
6257

63-
res.send({
64-
transactionIds: global.transactionIds || [],
65-
});
66-
});
58+
res.send({ status: 'ok' });
6759
});
68-
6960
app.get('/test-error', async function (req, res) {
7061
const exceptionId = Sentry.captureException(new Error('This is an error'));
7162

dev-packages/e2e-tests/test-applications/node-express/tests/transactions.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ test('Sends an API route transaction', async ({ baseURL }) => {
6262

6363
const spans = transactionEvent.spans || [];
6464

65+
// Manually started span
66+
expect(spans).toContainEqual({
67+
data: { 'sentry.origin': 'manual' },
68+
description: 'test-span',
69+
origin: 'manual',
70+
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
71+
span_id: expect.stringMatching(/[a-f0-9]{16}/),
72+
start_timestamp: expect.any(Number),
73+
status: 'ok',
74+
timestamp: expect.any(Number),
75+
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
76+
});
77+
78+
// auto instrumented spans
6579
expect(spans).toContainEqual({
6680
data: {
6781
'sentry.origin': 'auto.http.otel.express',

0 commit comments

Comments
 (0)