Skip to content

Commit eadfc90

Browse files
msonnbcodex
andcommitted
test(e2e): Migrate Express 4 and TSX to span streaming
Co-Authored-By: GPT-6 <codex@openai.com>
1 parent 37118dd commit eadfc90

10 files changed

Lines changed: 871 additions & 758 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ declare global {
99
}
1010

1111
Sentry.init({
12-
traceLifecycle: 'static',
1312
environment: 'qa', // dynamic sampling bias to keep transactions
1413
dsn: process.env.E2E_TEST_DSN,
1514
includeLocalVariables: true,

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import { expect, test } from '@playwright/test';
2-
import { waitForError, waitForTransaction } from '@sentry-internal/test-utils';
2+
import { waitForError, collectStreamedSpansUntilSegment } from '@sentry-internal/test-utils';
33

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

9-
const transactionEventPromise = waitForTransaction('node-express', event => {
10-
return event.transaction === 'GET /test-exception/:id';
11-
});
9+
const segmentEventPromise = collectStreamedSpansUntilSegment('node-express', 'GET /test-exception/:id');
1210

1311
await fetch(`${baseURL}/test-exception/123`);
1412

1513
const errorEvent = await errorEventPromise;
16-
const transactionEvent = await transactionEventPromise;
14+
const segmentEventSpans = await segmentEventPromise;
15+
const segmentEvent = segmentEventSpans.find(
16+
segment => segment.is_segment && segment.name === 'GET /test-exception/:id',
17+
)!;
1718

1819
expect(errorEvent.exception?.values).toHaveLength(1);
1920
const exception = errorEvent.exception?.values?.[0];
@@ -38,13 +39,18 @@ test('Sends correct error event', async ({ baseURL }) => {
3839
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
3940
});
4041

41-
// The error is attached to the same trace as the request transaction, and to a
42-
// span that belongs to that transaction (its root span or one of its children).
43-
const transactionTrace = transactionEvent.contexts?.trace;
44-
expect(errorEvent.contexts?.trace?.trace_id).toBe(transactionTrace?.trace_id);
42+
// The error is attached to the same trace as the request segment, and to a
43+
// span in that segment.
44+
const segmentTrace = segmentEvent;
45+
expect(errorEvent.contexts?.trace?.trace_id).toBe(segmentTrace?.trace_id);
4546

46-
const transactionSpanIds = [transactionTrace?.span_id, ...(transactionEvent.spans ?? []).map(span => span.span_id)];
47-
expect(transactionSpanIds).toContain(errorEvent.contexts?.trace?.span_id);
47+
const segmentSpanIds = [
48+
segmentTrace?.span_id,
49+
...segmentEventSpans
50+
.filter(span => !span.is_segment && span.attributes['sentry.segment.id']?.value === segmentEvent.span_id)
51+
.map(span => span.span_id),
52+
];
53+
expect(segmentSpanIds).toContain(errorEvent.contexts?.trace?.span_id);
4854
});
4955

5056
test('Should record caught exceptions with local variable', async ({ baseURL }) => {

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

Lines changed: 137 additions & 126 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)