mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
47 lines
1.8 KiB
TypeScript
47 lines
1.8 KiB
TypeScript
|
import type * as Sentry from '@sentry/vue';
|
||
|
import { beforeSend } from '@/plugins/sentry';
|
||
|
import { AxiosError } from 'axios';
|
||
|
import { ResponseError } from '@/utils/apiUtils';
|
||
|
|
||
|
function createErrorEvent(): Sentry.ErrorEvent {
|
||
|
return {} as Sentry.ErrorEvent;
|
||
|
}
|
||
|
|
||
|
describe('beforeSend', () => {
|
||
|
it('should return null when originalException is undefined', () => {
|
||
|
const event = createErrorEvent();
|
||
|
const hint = { originalException: undefined };
|
||
|
expect(beforeSend(event, hint)).toBeNull();
|
||
|
});
|
||
|
|
||
|
it('should return null when originalException matches ignoredErrors by instance and message', () => {
|
||
|
const event = createErrorEvent();
|
||
|
const hint = { originalException: new ResponseError("Can't connect to n8n.") };
|
||
|
expect(beforeSend(event, hint)).toBeNull();
|
||
|
});
|
||
|
|
||
|
it('should return null when originalException matches ignoredErrors by instance and message regex', () => {
|
||
|
const event = createErrorEvent();
|
||
|
const hint = { originalException: new ResponseError('ECONNREFUSED') };
|
||
|
expect(beforeSend(event, hint)).toBeNull();
|
||
|
});
|
||
|
|
||
|
it('should return null when originalException matches ignoredErrors by instance only', () => {
|
||
|
const event = createErrorEvent();
|
||
|
const hint = { originalException: new AxiosError() };
|
||
|
expect(beforeSend(event, hint)).toBeNull();
|
||
|
});
|
||
|
|
||
|
it('should return null when originalException matches ignoredErrors by instance and message regex (ResizeObserver)', () => {
|
||
|
const event = createErrorEvent();
|
||
|
const hint = { originalException: new Error('ResizeObserver loop limit exceeded') };
|
||
|
expect(beforeSend(event, hint)).toBeNull();
|
||
|
});
|
||
|
|
||
|
it('should return event when originalException does not match any ignoredErrors', () => {
|
||
|
const event = createErrorEvent();
|
||
|
const hint = { originalException: new Error('Some other error') };
|
||
|
expect(beforeSend(event, hint)).toEqual(event);
|
||
|
});
|
||
|
});
|