log-vista
Version:
LogVista Agent - Lightweight system monitoring and log collection for any project/language
56 lines (50 loc) • 1.45 kB
JavaScript
// Jest setup file
// This file is executed before each test file
// Increase timeout for longer running tests
jest.setTimeout(10000);
// Mock console methods to reduce test output noise
global.console = {
...console,
// Uncomment to silence console during tests
// log: jest.fn(),
// warn: jest.fn(),
// error: jest.fn(),
};
// Global test utilities
global.testUtils = {
// Helper to create temporary directories
createTempDir: () => {
const path = require('path');
const os = require('os');
return path.join(os.tmpdir(), 'logvista-test-' + Date.now() + '-' + Math.random().toString(36).substr(2, 9));
},
// Helper to create mock config
createMockConfig: (overrides = {}) => {
return {
central_system: {
url: 'http://localhost:3001',
token: 'test-token-123'
},
collection: {
interval: 30,
batch_size: 100,
retry_attempts: 3,
retry_delay: 1000
},
projects: [{
project_name: 'Test Project',
pwd_path: '/tmp/test',
custom_log_paths: ['logs/*.log'],
enabled: true
}],
...overrides
};
}
};
// Cleanup environment variables after tests
afterEach(() => {
// Clean up any environment variables set during tests
delete process.env.LOGVISTA_CONFIG;
delete process.env.LOGVISTA_TOKEN;
delete process.env.LOGVISTA_URL;
});