Skip to content

Commit

Permalink
test(core): Add comprehensive tests for ElizaLogger error handling (e…
Browse files Browse the repository at this point in the history
…lizaOS#1703) - Add test cases to verify error message display - Confirm logger correctly handles all error scenarios - Demonstrate proper error logging patterns - No issues found with error descriptions when used correctly
  • Loading branch information
AIFlowML committed Jan 3, 2025
1 parent 76d4f42 commit 64f0d6b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/core/src/tests/logger.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { elizaLogger } from '../logger';
import { describe, it, expect, beforeEach } from 'vitest';

describe('ElizaLogger Error Handling', () => {
beforeEach(() => {
// Reset logger state
elizaLogger.closeByNewLine = true;
elizaLogger.useIcons = true;
});

it('should properly log string error messages', () => {
elizaLogger.error('Simple error message');
});

it('should properly log Error objects', () => {
const error = new Error('Test error message');
elizaLogger.error('Error occurred:', error);
});

it('should properly log multiple arguments', () => {
elizaLogger.error(
'Failed to process request:',
{ id: 123, type: 'test' },
'Additional context:',
new Error('Network timeout')
);
});

it('should handle empty error messages', () => {
elizaLogger.error();
});

it('should properly log nested errors', () => {
try {
throw new Error('Inner error');
} catch (innerError) {
const outerError = new Error('Outer error');
// @ts-ignore - for testing
outerError.cause = innerError;
elizaLogger.error('Complex error:', outerError);
}
});
});

0 comments on commit 64f0d6b

Please sign in to comment.