-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy patherrors.test.ts
More file actions
41 lines (30 loc) · 1.55 KB
/
errors.test.ts
File metadata and controls
41 lines (30 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { expect, test } from '@playwright/test';
import { waitForError, waitForTransaction } from '@sentry-internal/test-utils';
test('Captures manually reported error in microservice handler', async ({ baseURL }) => {
const errorEventPromise = waitForError('nestjs-microservices', event => {
return !event.type && event.exception?.values?.[0]?.value === 'Manually captured microservice error';
});
await fetch(`${baseURL}/test-microservice-manual-capture`);
const errorEvent = await errorEventPromise;
expect(errorEvent.exception?.values).toHaveLength(1);
expect(errorEvent.exception?.values?.[0]?.value).toBe('Manually captured microservice error');
});
// To verify that an exception is NOT automatically captured, we trigger it,
// wait for the transaction from that request to confirm it completed, flush,
// and then assert no error event was received.
test('Does not automatically capture exceptions thrown in microservice handler', async ({ baseURL }) => {
let autoCaptureFired = false;
waitForError('nestjs-microservices', event => {
if (!event.type && event.exception?.values?.[0]?.value === 'Microservice exception with id 123') {
autoCaptureFired = true;
}
return false;
});
const transactionPromise = waitForTransaction('nestjs-microservices', transactionEvent => {
return transactionEvent?.transaction === 'GET /test-microservice-exception/:id';
});
await fetch(`${baseURL}/test-microservice-exception/123`);
await transactionPromise;
await fetch(`${baseURL}/flush`);
expect(autoCaptureFired).toBe(false);
});