Skip to content

Commit 705767c

Browse files
committed
Updates
1 parent c262235 commit 705767c

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

  • dev-packages/e2e-tests/test-applications/nestjs-microservices/tests

dev-packages/e2e-tests/test-applications/nestjs-microservices/tests/errors.test.ts

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

44
test('Captures manually reported error in microservice handler', async ({ baseURL }) => {
55
const errorEventPromise = waitForError('nestjs-microservices', event => {
@@ -14,11 +14,9 @@ test('Captures manually reported error in microservice handler', async ({ baseUR
1414
expect(errorEvent.exception?.values?.[0]?.value).toBe('Manually captured microservice error');
1515
});
1616

17-
// There is no good mechanism to verify that an event was NOT sent to Sentry.
18-
// The idea here is that we first send a message that triggers an exception which won't be auto-captured,
19-
// and then send a message that triggers a manually captured error which will be sent to Sentry.
20-
// If the manually captured error arrives, we can deduce that the first exception was not sent,
21-
// because both requests go through the same NestJS app and Sentry client, so events are processed in order.
17+
// To verify that an exception is NOT automatically captured, we trigger it,
18+
// wait for the transaction from that request to confirm it completed, flush,
19+
// and then assert no error event was received.
2220
test('Does not automatically capture exceptions thrown in microservice handler', async ({ baseURL }) => {
2321
let autoCaptureFired = false;
2422

@@ -29,14 +27,13 @@ test('Does not automatically capture exceptions thrown in microservice handler',
2927
return false;
3028
});
3129

32-
const manualCapturePromise = waitForError('nestjs-microservices', event => {
33-
return !event.type && event.exception?.values?.[0]?.value === 'Manually captured microservice error';
30+
const transactionPromise = waitForTransaction('nestjs-microservices', transactionEvent => {
31+
return transactionEvent?.transaction === 'GET /test-microservice-exception/:id';
3432
});
3533

3634
await fetch(`${baseURL}/test-microservice-exception/123`);
37-
await fetch(`${baseURL}/test-microservice-manual-capture`);
3835

39-
await manualCapturePromise;
36+
await transactionPromise;
4037

4138
await fetch(`${baseURL}/flush`);
4239

0 commit comments

Comments
 (0)