fixed logger tests
This commit is contained in:
parent
d836e766d5
commit
38b523d2c0
4 changed files with 21 additions and 19 deletions
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'bun:test';
|
||||
import { Logger } from '../src';
|
||||
import { Logger, shutdownLoggers } from '../src';
|
||||
import { loggerTestHelpers } from './setup';
|
||||
|
||||
describe('Advanced Logger Features', () => {
|
||||
|
|
@ -16,14 +16,10 @@ describe('Advanced Logger Features', () => {
|
|||
beforeEach(() => {
|
||||
testLoggerInstance = loggerTestHelpers.createTestLogger('advanced-features');
|
||||
logger = testLoggerInstance.logger;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
}); afterEach(async () => {
|
||||
testLoggerInstance.clearCapturedLogs();
|
||||
// Force garbage collection to clean up any potential circular references
|
||||
if (global.gc) {
|
||||
global.gc();
|
||||
}
|
||||
// Clear any global logger cache
|
||||
await shutdownLoggers();
|
||||
});
|
||||
|
||||
describe('Complex Metadata Handling', () => {
|
||||
|
|
@ -148,8 +144,7 @@ describe('Advanced Logger Features', () => {
|
|||
expect(logs.length).toBe(1);
|
||||
expect(logs[0].context).toBe('batch processing');
|
||||
});
|
||||
|
||||
it('should handle error objects with circular references', () => {
|
||||
it('should handle error objects with circular references', () => {
|
||||
const errorWithCircular: any = { name: 'CircularError', message: 'Circular reference error' };
|
||||
// Create a simple circular reference
|
||||
errorWithCircular.self = errorWithCircular;
|
||||
|
|
@ -162,6 +157,9 @@ describe('Advanced Logger Features', () => {
|
|||
const logs = testLoggerInstance.getCapturedLogs();
|
||||
expect(logs.length).toBe(1);
|
||||
expect(logs[0].level).toBe('error');
|
||||
|
||||
// Clean up circular reference to prevent memory issues
|
||||
delete errorWithCircular.self;
|
||||
});
|
||||
});
|
||||
describe('Performance and Edge Cases', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue