Skip to content

Commit 80b8cc6

Browse files
committed
Add ErrorBoundary propagation test.
1 parent 1ba4e89 commit 80b8cc6

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

dev-packages/e2e-tests/test-applications/create-remix-app-express/app/routes/client-error.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
import { useSearchParams } from '@remix-run/react';
2+
import * as Sentry from '@sentry/remix';
3+
14
import { useState } from 'react';
25

36
export default function ErrorBoundaryCapture() {
7+
const [searchParams] = useSearchParams();
8+
9+
if (searchParams.get('tag')) {
10+
Sentry.setTags({
11+
sentry_test: searchParams.get('tag'),
12+
});
13+
}
14+
415
const [count, setCount] = useState(0);
516

617
if (count > 0) {

dev-packages/e2e-tests/test-applications/create-remix-app-express/tests/behaviour-server.test.ts

+49
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,52 @@ test('Sends two linked transactions (server & client) to Sentry', async ({ page
105105
expect(pageLoadParentSpanId).toEqual(loaderSpanId);
106106
expect(pageLoadSpanId).not.toEqual(httpServerSpanId);
107107
});
108+
109+
test('Propagates trace when ErrorBoundary is triggered', async ({ page }) => {
110+
// We use this to identify the transactions
111+
const testTag = uuid4();
112+
113+
const httpServerTransactionPromise = waitForTransaction('create-remix-app-express', transactionEvent => {
114+
return (
115+
transactionEvent.type === 'transaction' &&
116+
transactionEvent.contexts?.trace?.op === 'http' &&
117+
transactionEvent.tags?.['sentry_test'] === testTag
118+
);
119+
});
120+
121+
const pageLoadTransactionPromise = waitForTransaction('create-remix-app-express', transactionEvent => {
122+
return (
123+
transactionEvent.type === 'transaction' &&
124+
transactionEvent.contexts?.trace?.op === 'pageload' &&
125+
transactionEvent.tags?.['sentry_test'] === testTag
126+
);
127+
});
128+
129+
page.goto(`/client-error?tag=${testTag}`);
130+
131+
const pageloadTransaction = await pageLoadTransactionPromise;
132+
const httpServerTransaction = await httpServerTransactionPromise;
133+
134+
expect(pageloadTransaction).toBeDefined();
135+
expect(httpServerTransaction).toBeDefined();
136+
137+
const httpServerTraceId = httpServerTransaction.contexts?.trace?.trace_id;
138+
const httpServerSpanId = httpServerTransaction.contexts?.trace?.span_id;
139+
const loaderSpanId = httpServerTransaction.spans.find(
140+
span => span.data && span.data['code.function'] === 'loader',
141+
)?.span_id;
142+
143+
const pageLoadTraceId = pageloadTransaction.contexts?.trace?.trace_id;
144+
const pageLoadSpanId = pageloadTransaction.contexts?.trace?.span_id;
145+
const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id;
146+
147+
expect(httpServerTransaction.transaction).toBe('GET client-error');
148+
expect(pageloadTransaction.transaction).toBe('routes/client-error');
149+
150+
expect(httpServerTraceId).toBeDefined();
151+
expect(httpServerSpanId).toBeDefined();
152+
153+
expect(pageLoadTraceId).toEqual(httpServerTraceId);
154+
expect(pageLoadParentSpanId).toEqual(loaderSpanId);
155+
expect(pageLoadSpanId).not.toEqual(httpServerSpanId);
156+
});

0 commit comments

Comments
 (0)