fix: enable glitchtip error reporting on the client side
This commit is contained in:
26
tests/create-services.test.ts
Normal file
26
tests/create-services.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { getAppServices } from '../lib/services/create-services';
|
||||
import { GlitchtipErrorReportingService } from '../lib/services/errors/glitchtip-error-reporting-service';
|
||||
|
||||
// Mock config to ensure sentry is enabled
|
||||
vi.mock('../lib/config', () => ({
|
||||
config: {
|
||||
analytics: { umami: { enabled: false } },
|
||||
errors: { glitchtip: { enabled: true, dsn: 'https://test@glitchtip.infra.mintel.me/5' } },
|
||||
logging: { level: 'info' },
|
||||
notifications: { gotify: { enabled: false } },
|
||||
},
|
||||
getMaskedConfig: () => ({}),
|
||||
}));
|
||||
|
||||
describe('AppServices (Client)', () => {
|
||||
beforeEach(() => {
|
||||
// Reset singleton
|
||||
globalThis.__appServices = undefined;
|
||||
});
|
||||
|
||||
it('should instantiate GlitchtipErrorReportingService when enabled', () => {
|
||||
const services = getAppServices();
|
||||
expect(services.errors).toBeInstanceOf(GlitchtipErrorReportingService);
|
||||
});
|
||||
});
|
||||
20
tests/sentry-config.test.ts
Normal file
20
tests/sentry-config.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import * as dotenv from 'dotenv';
|
||||
|
||||
describe('Sentry Configuration', () => {
|
||||
it('should have a valid SENTRY_DSN in .env', () => {
|
||||
// Read the .env file as a string
|
||||
const envPath = resolve(process.cwd(), '.env');
|
||||
const envContent = readFileSync(envPath, 'utf8');
|
||||
|
||||
// Parse it using dotenv
|
||||
const envConfig = dotenv.parse(envContent);
|
||||
|
||||
// Assert that SENTRY_DSN is defined and not empty
|
||||
expect(envConfig.SENTRY_DSN).toBeDefined();
|
||||
expect(envConfig.SENTRY_DSN.length).toBeGreaterThan(0);
|
||||
expect(envConfig.SENTRY_DSN).toMatch(/^https:\/\/.+@glitchtip.infra.mintel.me\/\d+$/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user