Files
RSSHub/lib/app-bootstrap.test.tsx
Tony 08a38f0a5e refactor: typing house-keeping (#23074)
* refactor: typing house-keeping

* fix: fix parse date not accepting strict mode

* refactor: use npm package

* fix: address review
2026-08-22 23:58:30 +08:00

23 lines
833 B
TypeScript

import { describe, expect, it, vi } from 'vitest';
import logger from '@/utils/logger';
describe('app-bootstrap', () => {
it('logs uncaught exceptions', async () => {
const errorSpy = vi.spyOn(logger, 'error').mockImplementation(() => logger);
const before = new Set(process.listeners('uncaughtException'));
await import('@/app-bootstrap');
const after = process.listeners('uncaughtException');
const listener = after.find((fn) => !before.has(fn) && String(fn).includes('uncaughtException: '));
expect(listener).toBeDefined();
listener?.(new Error('boom'), 'uncaughtException');
expect(errorSpy).toHaveBeenCalled();
if (listener) {
process.removeListener('uncaughtException', listener);
}
errorSpy.mockRestore();
});
});